---
title: 'Death Penalty Statutes and Murder Rates: Evidence from Synthetic Controls'
author: ' '
fontsize: 12pt
output:
 pdf_document: default
header-includes:
- \usepackage{setspace}\doublespacing
- \usepackage{placeins}
- \setlength\parindent{24pt}
- \usepackage[dvipsnames]{xcolor}
- \usepackage{float}
- \usepackage{array}
- \usepackage{booktabs}
- \usepackage[hang,flushmargin]{footmisc}
- \usepackage{rotating}
- \usepackage{caption}
- \usepackage{dcolumn}
- \usepackage{longtable}
abstract: \singlespacing \noindent Public debates over the death penalty in the U.S. have long focused on the punishment’s putative deterrent effect.  Unsurprisingly, numerous scholars have sought to determine (a) whether the penalty in fact prevents murders, and (b) how many murders it prevents.  However, these efforts have deployed a fairly homogeneous set of methodological techniques—primarily OLS and two-stage least squares with instrumental variables.  This article breaks from that tradition by using synthetic controls to assess the deterrent capacity of capital punishment.  Applying this technique using seven states that recently abolished the death penalty and twenty-nine states that retained the punishment during the same period, I find no evidence that the presence of a capital punishment statute in a state is sufficient to deter murders.  These results are robust to numerous alternative specifications; they also persist when I use stranger homicides—which are theoretically more susceptible to deterrence—as the dependent variable.
---

\thispagestyle{empty}

\newpage
\clearpage
\pagenumbering{arabic} 

```{r project, include=F}
#### PLEASE NOTE THAT THIS CODE TAKES SEVERAL HOURS TO RUN IN TOTAL

### SET WORKING DIRECTORY AS APPROPRIATE, e.g., setwd("~/Desktop/Datasets")

##### SCD Cleaning

cleaned.data <- read.csv("clean.murder.crime.csv")

inequality <- read.csv("inequality.one.percent.csv")

age.data <- read.csv("age.stats.csv")

age.data$State <- as.character(age.data$State)

cleaned.data$log.murder.rate <- log(cleaned.data$Murder.Rate)

unemployment.data <- read.csv("State.Unemployment.By.Year.csv")

pop.density <- read.csv("pop.density.csv")

per.capita.gdp <- read.csv("per.capital.gdp.2012.csv")

poverty <- read.csv("poverty.csv")

police <- read.csv("police.expenditures.csv")

stranger.homicides <- read.csv("stranger.homicides.csv")

intimate.homicides <- read.csv("intimate.homicides.csv")

acquaintance.homicides <- read.csv("acquaintance.homicides.csv")

incarceration.data <- read.csv("incarceration.data.csv")
incarceration.data$State <- as.character(incarceration.data$State)

police.employees <- read.csv("pe_1960_2019.csv")

police.employees <- police.employees[police.employees$Year>=1995,]


police$police.direct.expen.pc <- as.numeric(police$police.direct.expen.pc)

police$State <- as.character(police$State)

stranger.homicides$State <- as.character(stranger.homicides$state)

stranger.homicides$Year <- stranger.homicides$year

intimate.homicides$State <- as.character(intimate.homicides$state)

intimate.homicides$Year <- intimate.homicides$year

acquaintance.homicides$State <- as.character(acquaintance.homicides$state)

acquaintance.homicides$Year <- acquaintance.homicides$year

stranger.homicides$year <- NULL

stranger.homicides$state <- NULL

intimate.homicides$year <- NULL

intimate.homicides$state <- NULL

acquaintance.homicides$year <- NULL

acquaintance.homicides$state <- NULL

poverty$State <- as.character(poverty$State)
poverty$poverty <- as.numeric(poverty$poverty)

library(tidyr)
library(lfe)
library(foreign)
library(knitr)
library(car)
library(sandwich)
library(lmtest)
library(plm)
library(stargazer)
library(broom)
library(dotwhisker)
library(MASS)
library(plyr)
library(dplyr)

###########################

pop.density_long <- pop.density %>% gather(key = "Year", value = "pop.den", 3:34)

pop.density_long <- pop.density_long %>% mutate(Year = as.numeric(gsub("X", "", Year)))

pop.density_long$State <- as.character(pop.density_long$Area)

pop.density_long <- pop.density_long %>% mutate(pop.den = as.numeric(gsub(",", "", pop.den)))

pop.density_long$pop.den.n <- as.numeric(pop.density_long$pop.den)



gdp_long <- per.capita.gdp %>% gather(key = "Year", value = "gdp.per", 2:33)

gdp_long <- gdp_long %>% mutate(Year = as.numeric(gsub("X", "", Year)))

gdp_long$State <- as.character(gdp_long$Area)

gdp_long <- gdp_long %>% mutate(gdp.per = as.numeric(gsub(",", "", gdp.per)))

gdp_long$gdp.per.n <- as.numeric(gdp_long$gdp.per)

inequality$State <- as.character(inequality$State)


incarceration.data_long <- incarceration.data %>% gather(key = "Year", value = "prison.rate", 2:22)

incarceration.data_long <- incarceration.data_long %>% mutate(Year = as.numeric(gsub("X", "", Year)))

incarceration.data_long$State <- as.character(incarceration.data_long$State)

incarceration.data_long <- incarceration.data_long %>% mutate(prison.rate = as.numeric(gsub(",", "", prison.rate)))

incarceration.data_long$prison.rate.n <- as.numeric(incarceration.data_long$prison.rate)

###########################



crimes <- read.csv("estimated_crimes.csv")
crimes$State <- as.factor(revalue(crimes$state_abbr, c(
  "AR" = "Arkansas",
  "AL" = "Alabama",
  "FL" = "Florida",
  "GA" = "Georgia",
  "LA" = "Louisiana",
  "MS" = "Mississippi",
  "NC" = "North Carolina",
  "SC" = "South Carolina",
  "TN" = "Tennessee",
  "VA" = "Virginia",
  "KY" = "Kentucky",
  "MD" = "Maryland",
  "MO" = "Missouri",
  "WV" = "West Virginia",
  "AZ" = "Arizona",
  "NM" = "New Mexico",
  "OK" = "Oklahoma",
  "TX" = "Texas",
  "CO" = "Colorado",
  "ID" = "Idaho",
  "MT" = "Montana",
  "NV" = "Nevada",
  "UT" = "Utah",
  "WY" = "Wyoming",
  "CT" = "Connecticut",
  "ME" = "Maine",
  "MA" = "Massachusetts",
  "NH" = "New Hampshire",
  "RI" = "Rhode Island",
  "VT" = "Vermont",
  "CA" = "California",
  "OR" = "Oregon",
  "WA" = "Washington",
  "DE" = "Delaware",
  "NJ" = "New Jersey",
  "NY" = "New York",
  "PA" = "Pennsylvania",
  "IL" = "Illinois",
  "IN" = "Indiana",
  "MI" = "Michigan",
  "MN" = "Minnesota",
  "OH" = "Ohio",
  "WI" = "Wisconsin",
  "IA" = "Iowa",
  "KS" = "Kansas",
  "NE" = "Nebraska",
  "ND" = "North Dakota",
  "SD" = "South Dakota",
  "AK" = "Alaska",
  "HI" = "Hawaii"
)))



police.employees$State <- as.factor(revalue(police.employees$state_abbr, c(
  "AR" = "Arkansas",
  "AL" = "Alabama",
  "FL" = "Florida",
  "GA" = "Georgia",
  "LA" = "Louisiana",
  "MS" = "Mississippi",
  "NC" = "North Carolina",
  "SC" = "South Carolina",
  "TN" = "Tennessee",
  "VA" = "Virginia",
  "KY" = "Kentucky",
  "MD" = "Maryland",
  "MO" = "Missouri",
  "WV" = "West Virginia",
  "AZ" = "Arizona",
  "NM" = "New Mexico",
  "OK" = "Oklahoma",
  "TX" = "Texas",
  "CO" = "Colorado",
  "ID" = "Idaho",
  "MT" = "Montana",
  "NV" = "Nevada",
  "UT" = "Utah",
  "WY" = "Wyoming",
  "CT" = "Connecticut",
  "ME" = "Maine",
  "MA" = "Massachusetts",
  "NH" = "New Hampshire",
  "RI" = "Rhode Island",
  "VT" = "Vermont",
  "CA" = "California",
  "OR" = "Oregon",
  "WA" = "Washington",
  "DE" = "Delaware",
  "NJ" = "New Jersey",
  "NY" = "New York",
  "PA" = "Pennsylvania",
  "IL" = "Illinois",
  "IN" = "Indiana",
  "MI" = "Michigan",
  "MN" = "Minnesota",
  "OH" = "Ohio",
  "WI" = "Wisconsin",
  "IA" = "Iowa",
  "KS" = "Kansas",
  "NE" = "Nebraska",
  "ND" = "North Dakota",
  "SD" = "South Dakota",
  "AK" = "Alaska",
  "HI" = "Hawaii"
)))


police.employees <- police.employees[police.employees$state_abbr!="AS"  & police.employees$state_abbr!="CZ" & police.employees$state_abbr!="FS" & police.employees$state_abbr!="GM" & police.employees$state_abbr!="MP" & police.employees$state_abbr!="OT"
& police.employees$state_abbr!="PR" & police.employees$state_abbr!="VI" & police.employees$state_abbr!="DC",]

police.employees$State <- as.character(police.employees$State)


crimes$State <- as.character(crimes$State)
crimes$Year <- crimes$year

cleaned.data <- cleaned.data[cleaned.data$Year>=1995,]

cleaned.data$crime.rate <- cleaned.data$property_crime/cleaned.data$population

cleaned.data$State <- as.character(cleaned.data$State)

unemployment.data$State <- as.character(unemployment.data$State)

crimes$robbery.rate <- crimes$robbery/crimes$population

###### For Panel Data ######
murder.rates <- read.csv("Murder.Death.Penalty.csv")

murder.rates$Death.Penalty.Numeric <- ifelse(murder.rates$Death.Penalty=="Death Penalty", 1, 0)

murder.rates.grouped <- murder.rates %>% arrange(State, Year)  

states.the.change <- murder.rates.grouped[(murder.rates.grouped$State=="New York" | murder.rates.grouped$State=="Maryland" | murder.rates.grouped$State=="Delaware" | murder.rates.grouped$State =="Illinois" | murder.rates.grouped$State =="New Mexico" | murder.rates.grouped$State == "Connecticut" | murder.rates.grouped$State=="New Jersey" | murder.rates.grouped$State == "Nebraska"),]

panel.data <- merge(unemployment.data, states.the.change, all.y = T, by = c("State", "Year"))

panel.data <- merge(crimes, panel.data, all.y = T, by = c("State", "Year"))

panel.data <- merge(pop.density_long, panel.data, all.y = T, by = c("State", "Year"))

panel.data <- merge(age.data, panel.data, all.y = T, by = c("State", "Year"))

crimes$population <- NULL

################

cleaned.data <- merge(unemployment.data, cleaned.data, all.y = T, by = c("State", "Year"))

cleaned.data <- merge(crimes, cleaned.data, all.y = T, by = c("State", "Year"))

cleaned.data <- merge(pop.density_long, cleaned.data, all.y = T, by = c("State", "Year"))

cleaned.data <- merge(age.data, cleaned.data, all.y = T, by = c("State", "Year"))

cleaned.data <- merge(gdp_long, cleaned.data, all.y = T, by = c("State", "Year"))

cleaned.data <- merge(inequality, cleaned.data, all.y = T, by = c("State", "Year"))

cleaned.data <- merge(poverty, cleaned.data, all.y = T, by = c("State", "Year"))

cleaned.data <- merge(police, cleaned.data, all.y = T, by = c("State", "Year"))

cleaned.data <- merge(stranger.homicides, cleaned.data, all.y = T, by = c("State", "Year"))

cleaned.data <- merge(intimate.homicides, cleaned.data, all.y = T, by = c("State", "Year"))

cleaned.data <- merge(acquaintance.homicides, cleaned.data, all.y = T, by = c("State", "Year"))

cleaned.data <- merge(incarceration.data_long, cleaned.data, all.y = T, by = c("State", "Year"))

police.employees$population <- NULL

cleaned.data <- merge(police.employees, cleaned.data, all.y = T, by = c("State", "Year"))


cleaned.data$proportion.15.29 <- cleaned.data$age.15.29/cleaned.data$population

cleaned.data$stranger.homicide.rate <- 100000*(cleaned.data$stranger.homicides/cleaned.data$population)

cleaned.data$intimate.homicide.rate <- 100000*(cleaned.data$intimate.homicides/cleaned.data$population)

cleaned.data$acquaintance.homicide.rate <- 100000*(cleaned.data$acquaintance.homicides/cleaned.data$population)


i <- 1
ny.lag.1 <- vector()
ny.lag.5 <- vector()
ny.lag.9 <- vector()
nm.lag.1 <- vector()
nm.lag.7 <- vector()
nm.lag.14 <- vector()
illinois.lag.1 <- vector()
illinois.lag.8 <- vector()
illinois.lag.16 <- vector()
conn.lag.1 <- vector()
conn.lag.9 <- vector()
conn.lag.17 <- vector()
nj.lag.1 <- vector()
nj.lag.6 <- vector()
nj.lag.12 <- vector()
del.lag.1 <- vector()
del.lag.11 <- vector()
del.lag.21 <- vector()
maryland.lag.1 <- vector()
maryland.lag.9 <- vector()
maryland.lag.18 <- vector()



for (s in unique(cleaned.data$State)) {
  ny.lag.1[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2003,]$log.murder.rate
  ny.lag.5[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1999,]$log.murder.rate
  ny.lag.9[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$log.murder.rate
  nm.lag.1[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2008,]$log.murder.rate
  nm.lag.7[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2002,]$log.murder.rate
  nm.lag.14[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$log.murder.rate
  illinois.lag.1[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2010,]$log.murder.rate
  illinois.lag.8[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2003,]$log.murder.rate
  illinois.lag.16[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$log.murder.rate
  conn.lag.1[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2011,]$log.murder.rate
  conn.lag.9[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2003,]$log.murder.rate
  conn.lag.17[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$log.murder.rate
  nj.lag.1[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2006,]$log.murder.rate
  nj.lag.6[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2001,]$log.murder.rate
  nj.lag.12[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$log.murder.rate
  del.lag.1[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2015,]$log.murder.rate
  del.lag.11[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2005,]$log.murder.rate
  del.lag.21[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$log.murder.rate
  maryland.lag.1[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2012,]$log.murder.rate
  maryland.lag.9[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2004,]$log.murder.rate
  maryland.lag.18[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$log.murder.rate
  i <- i + 1
}

cleaned.data$ny.lag.1 <- rep(ny.lag.1, each = 24)
cleaned.data$ny.lag.5 <- rep(ny.lag.5, each = 24)
cleaned.data$ny.lag.9 <- rep(ny.lag.9, each = 24)
cleaned.data$nm.lag.1 <- rep(nm.lag.1, each = 24)
cleaned.data$nm.lag.7 <- rep(nm.lag.7, each = 24)
cleaned.data$nm.lag.14 <- rep(nm.lag.14, each = 24)
cleaned.data$illinois.lag.1 <- rep(illinois.lag.1, each = 24)
cleaned.data$illinois.lag.8 <- rep(illinois.lag.8, each = 24)
cleaned.data$illinois.lag.16 <- rep(illinois.lag.16, each = 24)
cleaned.data$conn.lag.1 <- rep(conn.lag.1, each = 24)
cleaned.data$conn.lag.9 <- rep(conn.lag.9, each = 24)
cleaned.data$conn.lag.17 <- rep(conn.lag.17, each = 24)
cleaned.data$nj.lag.1 <- rep(nj.lag.1, each = 24)
cleaned.data$nj.lag.6 <- rep(nj.lag.6, each = 24)
cleaned.data$nj.lag.12 <- rep(nj.lag.12, each = 24)
cleaned.data$del.lag.1 <- rep(del.lag.1, each = 24)
cleaned.data$del.lag.11 <- rep(del.lag.11, each = 24)
cleaned.data$del.lag.21 <- rep(del.lag.21, each = 24)
cleaned.data$maryland.lag.1 <- rep(maryland.lag.1, each = 24)
cleaned.data$maryland.lag.9 <- rep(maryland.lag.9, each = 24)
cleaned.data$maryland.lag.18 <- rep(maryland.lag.18, each = 24)


i <- 1
ny.lag.1.stranger <- vector()
ny.lag.5.stranger <- vector()
ny.lag.9.stranger <- vector()
nm.lag.1.stranger <- vector()
nm.lag.7.stranger <- vector()
nm.lag.14.stranger <- vector()
illinois.lag.1.stranger <- vector()
illinois.lag.8.stranger <- vector()
illinois.lag.16.stranger <- vector()
conn.lag.1.stranger <- vector()
conn.lag.9.stranger <- vector()
conn.lag.17.stranger <- vector()
nj.lag.1.stranger <- vector()
nj.lag.6.stranger <- vector()
nj.lag.12.stranger <- vector()
del.lag.1.stranger <- vector()
del.lag.11.stranger <- vector()
del.lag.21.stranger <- vector()
maryland.lag.1.stranger <- vector()
maryland.lag.9.stranger <- vector()
maryland.lag.18.stranger <- vector()



for (s in unique(cleaned.data$State)) {
  ny.lag.1.stranger[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2003,]$stranger.homicide.rate
  ny.lag.5.stranger[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1999,]$stranger.homicide.rate
  ny.lag.9.stranger[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$stranger.homicide.rate
  nm.lag.1.stranger[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2008,]$stranger.homicide.rate
  nm.lag.7.stranger[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2002,]$stranger.homicide.rate
  nm.lag.14.stranger[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$stranger.homicide.rate
  illinois.lag.1.stranger[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2010,]$stranger.homicide.rate
  illinois.lag.8.stranger[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2003,]$stranger.homicide.rate
  illinois.lag.16.stranger[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$stranger.homicide.rate
  conn.lag.1.stranger[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2011,]$stranger.homicide.rate
  conn.lag.9.stranger[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2003,]$stranger.homicide.rate
  conn.lag.17.stranger[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$stranger.homicide.rate
  nj.lag.1.stranger[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2006,]$stranger.homicide.rate
  nj.lag.6.stranger[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2001,]$stranger.homicide.rate
  nj.lag.12.stranger[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$stranger.homicide.rate
  del.lag.1.stranger[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2015,]$stranger.homicide.rate
  del.lag.11.stranger[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2005,]$stranger.homicide.rate
  del.lag.21.stranger[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1996,]$stranger.homicide.rate
  maryland.lag.1.stranger[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2012,]$stranger.homicide.rate
  maryland.lag.9.stranger[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2004,]$stranger.homicide.rate
  maryland.lag.18.stranger[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$stranger.homicide.rate
  i <- i + 1
}

cleaned.data$ny.lag.1.stranger <- rep(ny.lag.1.stranger, each = 24)
cleaned.data$ny.lag.5.stranger <- rep(ny.lag.5.stranger, each = 24)
cleaned.data$ny.lag.9.stranger <- rep(ny.lag.9.stranger, each = 24)
cleaned.data$nm.lag.1.stranger <- rep(nm.lag.1.stranger, each = 24)
cleaned.data$nm.lag.7.stranger <- rep(nm.lag.7.stranger, each = 24)
cleaned.data$nm.lag.14.stranger <- rep(nm.lag.14.stranger, each = 24)
cleaned.data$illinois.lag.1.stranger <- rep(illinois.lag.1.stranger, each = 24)
cleaned.data$illinois.lag.8.stranger <- rep(illinois.lag.8.stranger, each = 24)
cleaned.data$illinois.lag.16.stranger <- rep(illinois.lag.16.stranger, each = 24)
cleaned.data$conn.lag.1.stranger <- rep(conn.lag.1.stranger, each = 24)
cleaned.data$conn.lag.9.stranger <- rep(conn.lag.9.stranger, each = 24)
cleaned.data$conn.lag.17.stranger <- rep(conn.lag.17.stranger, each = 24)
cleaned.data$nj.lag.1.stranger <- rep(nj.lag.1.stranger, each = 24)
cleaned.data$nj.lag.6.stranger <- rep(nj.lag.6.stranger, each = 24)
cleaned.data$nj.lag.12.stranger <- rep(nj.lag.12.stranger, each = 24)
cleaned.data$del.lag.1.stranger <- rep(del.lag.1.stranger, each = 24)
cleaned.data$del.lag.11.stranger <- rep(del.lag.11.stranger, each = 24)
cleaned.data$del.lag.21.stranger <- rep(del.lag.21.stranger, each = 24)
cleaned.data$maryland.lag.1.stranger <- rep(maryland.lag.1.stranger, each = 24)
cleaned.data$maryland.lag.9.stranger <- rep(maryland.lag.9.stranger, each = 24)
cleaned.data$maryland.lag.18.stranger <- rep(maryland.lag.18.stranger, each = 24)

i <- 1
ny.lag.1.intimate <- vector()
ny.lag.5.intimate <- vector()
ny.lag.9.intimate <- vector()
nm.lag.1.intimate <- vector()
nm.lag.7.intimate <- vector()
nm.lag.14.intimate <- vector()
illinois.lag.1.intimate <- vector()
illinois.lag.8.intimate <- vector()
illinois.lag.16.intimate <- vector()
conn.lag.1.intimate <- vector()
conn.lag.9.intimate <- vector()
conn.lag.17.intimate <- vector()
nj.lag.1.intimate <- vector()
nj.lag.6.intimate <- vector()
nj.lag.12.intimate <- vector()
del.lag.1.intimate <- vector()
del.lag.11.intimate <- vector()
del.lag.21.intimate <- vector()
maryland.lag.1.intimate <- vector()
maryland.lag.9.intimate <- vector()
maryland.lag.18.intimate <- vector()



for (s in unique(cleaned.data$State)) {
  ny.lag.1.intimate[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2003,]$intimate.homicide.rate
  ny.lag.5.intimate[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1999,]$intimate.homicide.rate
  ny.lag.9.intimate[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$intimate.homicide.rate
  nm.lag.1.intimate[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2008,]$intimate.homicide.rate
  nm.lag.7.intimate[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2002,]$intimate.homicide.rate
  nm.lag.14.intimate[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$intimate.homicide.rate
  illinois.lag.1.intimate[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2010,]$intimate.homicide.rate
  illinois.lag.8.intimate[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2003,]$intimate.homicide.rate
  illinois.lag.16.intimate[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$intimate.homicide.rate
  conn.lag.1.intimate[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2011,]$intimate.homicide.rate
  conn.lag.9.intimate[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2003,]$intimate.homicide.rate
  conn.lag.17.intimate[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$intimate.homicide.rate
  nj.lag.1.intimate[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2006,]$intimate.homicide.rate
  nj.lag.6.intimate[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2001,]$intimate.homicide.rate
  nj.lag.12.intimate[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$intimate.homicide.rate
  del.lag.1.intimate[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2015,]$intimate.homicide.rate
  del.lag.11.intimate[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2005,]$intimate.homicide.rate
  del.lag.21.intimate[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1996,]$intimate.homicide.rate
  maryland.lag.1.intimate[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2012,]$intimate.homicide.rate
  maryland.lag.9.intimate[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2004,]$intimate.homicide.rate
  maryland.lag.18.intimate[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$intimate.homicide.rate
  i <- i + 1
}

cleaned.data$ny.lag.1.intimate <- rep(ny.lag.1.intimate, each = 24)
cleaned.data$ny.lag.5.intimate <- rep(ny.lag.5.intimate, each = 24)
cleaned.data$ny.lag.9.intimate <- rep(ny.lag.9.intimate, each = 24)
cleaned.data$nm.lag.1.intimate <- rep(nm.lag.1.intimate, each = 24)
cleaned.data$nm.lag.7.intimate <- rep(nm.lag.7.intimate, each = 24)
cleaned.data$nm.lag.14.intimate <- rep(nm.lag.14.intimate, each = 24)
cleaned.data$illinois.lag.1.intimate <- rep(illinois.lag.1.intimate, each = 24)
cleaned.data$illinois.lag.8.intimate <- rep(illinois.lag.8.intimate, each = 24)
cleaned.data$illinois.lag.16.intimate <- rep(illinois.lag.16.intimate, each = 24)
cleaned.data$conn.lag.1.intimate <- rep(conn.lag.1.intimate, each = 24)
cleaned.data$conn.lag.9.intimate <- rep(conn.lag.9.intimate, each = 24)
cleaned.data$conn.lag.17.intimate <- rep(conn.lag.17.intimate, each = 24)
cleaned.data$nj.lag.1.intimate <- rep(nj.lag.1.intimate, each = 24)
cleaned.data$nj.lag.6.intimate <- rep(nj.lag.6.intimate, each = 24)
cleaned.data$nj.lag.12.intimate <- rep(nj.lag.12.intimate, each = 24)
cleaned.data$del.lag.1.intimate <- rep(del.lag.1.intimate, each = 24)
cleaned.data$del.lag.11.intimate <- rep(del.lag.11.intimate, each = 24)
cleaned.data$del.lag.21.intimate <- rep(del.lag.21.intimate, each = 24)
cleaned.data$maryland.lag.1.intimate <- rep(maryland.lag.1.intimate, each = 24)
cleaned.data$maryland.lag.9.intimate <- rep(maryland.lag.9.intimate, each = 24)
cleaned.data$maryland.lag.18.intimate <- rep(maryland.lag.18.intimate, each = 24)

i <- 1
ny.lag.1.acquaintance <- vector()
ny.lag.5.acquaintance <- vector()
ny.lag.9.acquaintance <- vector()
nm.lag.1.acquaintance <- vector()
nm.lag.7.acquaintance <- vector()
nm.lag.14.acquaintance <- vector()
illinois.lag.1.acquaintance <- vector()
illinois.lag.8.acquaintance <- vector()
illinois.lag.16.acquaintance <- vector()
conn.lag.1.acquaintance <- vector()
conn.lag.9.acquaintance <- vector()
conn.lag.17.acquaintance <- vector()
nj.lag.1.acquaintance <- vector()
nj.lag.6.acquaintance <- vector()
nj.lag.12.acquaintance <- vector()
del.lag.1.acquaintance <- vector()
del.lag.11.acquaintance <- vector()
del.lag.21.acquaintance <- vector()
maryland.lag.1.acquaintance <- vector()
maryland.lag.9.acquaintance <- vector()
maryland.lag.18.acquaintance <- vector()



for (s in unique(cleaned.data$State)) {
  ny.lag.1.acquaintance[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2003,]$acquaintance.homicide.rate
  ny.lag.5.acquaintance[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1999,]$acquaintance.homicide.rate
  ny.lag.9.acquaintance[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$acquaintance.homicide.rate
  nm.lag.1.acquaintance[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2008,]$acquaintance.homicide.rate
  nm.lag.7.acquaintance[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2002,]$acquaintance.homicide.rate
  nm.lag.14.acquaintance[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$acquaintance.homicide.rate
  illinois.lag.1.acquaintance[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2010,]$acquaintance.homicide.rate
  illinois.lag.8.acquaintance[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2003,]$acquaintance.homicide.rate
  illinois.lag.16.acquaintance[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$acquaintance.homicide.rate
  conn.lag.1.acquaintance[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2011,]$acquaintance.homicide.rate
  conn.lag.9.acquaintance[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2003,]$acquaintance.homicide.rate
  conn.lag.17.acquaintance[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$acquaintance.homicide.rate
  nj.lag.1.acquaintance[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2006,]$acquaintance.homicide.rate
  nj.lag.6.acquaintance[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2001,]$acquaintance.homicide.rate
  nj.lag.12.acquaintance[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$acquaintance.homicide.rate
  del.lag.1.acquaintance[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2015,]$acquaintance.homicide.rate
  del.lag.11.acquaintance[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2005,]$acquaintance.homicide.rate
  del.lag.21.acquaintance[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1996,]$acquaintance.homicide.rate
  maryland.lag.1.acquaintance[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2012,]$acquaintance.homicide.rate
  maryland.lag.9.acquaintance[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2004,]$acquaintance.homicide.rate
  maryland.lag.18.acquaintance[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$acquaintance.homicide.rate
  i <- i + 1
}

cleaned.data$ny.lag.1.acquaintance <- rep(ny.lag.1.acquaintance, each = 24)
cleaned.data$ny.lag.5.acquaintance <- rep(ny.lag.5.acquaintance, each = 24)
cleaned.data$ny.lag.9.acquaintance <- rep(ny.lag.9.acquaintance, each = 24)
cleaned.data$nm.lag.1.acquaintance <- rep(nm.lag.1.acquaintance, each = 24)
cleaned.data$nm.lag.7.acquaintance <- rep(nm.lag.7.acquaintance, each = 24)
cleaned.data$nm.lag.14.acquaintance <- rep(nm.lag.14.acquaintance, each = 24)
cleaned.data$illinois.lag.1.acquaintance <- rep(illinois.lag.1.acquaintance, each = 24)
cleaned.data$illinois.lag.8.acquaintance <- rep(illinois.lag.8.acquaintance, each = 24)
cleaned.data$illinois.lag.16.acquaintance <- rep(illinois.lag.16.acquaintance, each = 24)
cleaned.data$conn.lag.1.acquaintance <- rep(conn.lag.1.acquaintance, each = 24)
cleaned.data$conn.lag.9.acquaintance <- rep(conn.lag.9.acquaintance, each = 24)
cleaned.data$conn.lag.17.acquaintance <- rep(conn.lag.17.acquaintance, each = 24)
cleaned.data$nj.lag.1.acquaintance <- rep(nj.lag.1.acquaintance, each = 24)
cleaned.data$nj.lag.6.acquaintance <- rep(nj.lag.6.acquaintance, each = 24)
cleaned.data$nj.lag.12.acquaintance <- rep(nj.lag.12.acquaintance, each = 24)
cleaned.data$del.lag.1.acquaintance <- rep(del.lag.1.acquaintance, each = 24)
cleaned.data$del.lag.11.acquaintance <- rep(del.lag.11.acquaintance, each = 24)
cleaned.data$del.lag.21.acquaintance <- rep(del.lag.21.acquaintance, each = 24)
cleaned.data$maryland.lag.1.acquaintance <- rep(maryland.lag.1.acquaintance, each = 24)
cleaned.data$maryland.lag.9.acquaintance <- rep(maryland.lag.9.acquaintance, each = 24)
cleaned.data$maryland.lag.18.acquaintance <- rep(maryland.lag.18.acquaintance, each = 24)




ny.lag.new.1 <- vector()
ny.lag.new.5 <- vector()
ny.lag.new.9 <- vector()
nm.lag.new.1 <- vector()
nm.lag.new.7 <- vector()
nm.lag.new.14 <- vector()
illinois.lag.new.1 <- vector()
illinois.lag.new.8 <- vector()
illinois.lag.new.16 <- vector()
conn.lag.new.1 <- vector()
conn.lag.new.9 <- vector()
conn.lag.new.17 <- vector()
nj.lag.new.1 <- vector()
nj.lag.new.6 <- vector()
nj.lag.new.12 <- vector()
del.lag.new.1 <- vector()
del.lag.new.11 <- vector()
del.lag.new.21 <- vector()
maryland.lag.new.1 <- vector()
maryland.lag.new.9 <- vector()
maryland.lag.new.18 <- vector()


i <- 1
for (s in unique(cleaned.data$State)) {
  ny.lag.new.1[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2002,]$log.murder.rate
  ny.lag.new.5[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1998,]$log.murder.rate
  ny.lag.new.9[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$log.murder.rate
  nm.lag.new.1[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2006,]$log.murder.rate
  nm.lag.new.7[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2001,]$log.murder.rate
  nm.lag.new.14[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$log.murder.rate
  illinois.lag.new.1[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2008,]$log.murder.rate
  illinois.lag.new.8[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2002,]$log.murder.rate
  illinois.lag.new.16[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$log.murder.rate
  conn.lag.new.1[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2009,]$log.murder.rate
  conn.lag.new.9[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2002,]$log.murder.rate
  conn.lag.new.17[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$log.murder.rate
  nj.lag.new.1[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2004,]$log.murder.rate
  nj.lag.new.6[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2000,]$log.murder.rate
  nj.lag.new.12[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$log.murder.rate
  del.lag.new.1[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2013,]$log.murder.rate
  del.lag.new.11[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2004,]$log.murder.rate
  del.lag.new.21[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$log.murder.rate
  maryland.lag.new.1[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2010,]$log.murder.rate
  maryland.lag.new.9[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==2003,]$log.murder.rate
  maryland.lag.new.18[i] <- cleaned.data[cleaned.data$State == s & cleaned.data$Year==1995,]$log.murder.rate
  i <- i + 1
}

cleaned.data$ny.lag.new.1 <- rep(ny.lag.new.1, each = 24)
cleaned.data$ny.lag.new.5 <- rep(ny.lag.new.5, each = 24)
cleaned.data$ny.lag.new.9 <- rep(ny.lag.new.9, each = 24)
cleaned.data$nm.lag.new.1 <- rep(nm.lag.new.1, each = 24)
cleaned.data$nm.lag.new.7 <- rep(nm.lag.new.7, each = 24)
cleaned.data$nm.lag.new.14 <- rep(nm.lag.new.14, each = 24)
cleaned.data$illinois.lag.new.1 <- rep(illinois.lag.new.1, each = 24)
cleaned.data$illinois.lag.new.8 <- rep(illinois.lag.new.8, each = 24)
cleaned.data$illinois.lag.new.16 <- rep(illinois.lag.new.16, each = 24)
cleaned.data$conn.lag.new.1 <- rep(conn.lag.new.1, each = 24)
cleaned.data$conn.lag.new.9 <- rep(conn.lag.new.9, each = 24)
cleaned.data$conn.lag.new.17 <- rep(conn.lag.new.17, each = 24)
cleaned.data$nj.lag.new.1 <- rep(nj.lag.new.1, each = 24)
cleaned.data$nj.lag.new.6 <- rep(nj.lag.new.6, each = 24)
cleaned.data$nj.lag.new.12 <- rep(nj.lag.new.12, each = 24)
cleaned.data$del.lag.new.1 <- rep(del.lag.new.1, each = 24)
cleaned.data$del.lag.new.11 <- rep(del.lag.new.11, each = 24)
cleaned.data$del.lag.new.21 <- rep(del.lag.new.21, each = 24)
cleaned.data$maryland.lag.new.1 <- rep(maryland.lag.new.1, each = 24)
cleaned.data$maryland.lag.new.9 <- rep(maryland.lag.new.9, each = 24)
cleaned.data$maryland.lag.new.18 <- rep(maryland.lag.new.18, each = 24)

i <- 1
ny.lag.whole <- vector()
nm.lag.whole <- vector()
illinois.lag.whole <- vector()
conn.lag.whole <- vector()
nj.lag.whole <- vector()
del.lag.whole <- vector()
maryland.lag.whole <- vector()



for (s in unique(cleaned.data$State)) {
  ny.lag.whole[i] <- mean(cleaned.data[cleaned.data$State == s & cleaned.data$Year<=2003,]$log.murder.rate, na.rm = T)
  nm.lag.whole[i] <- mean(cleaned.data[cleaned.data$State == s & cleaned.data$Year<=2008,]$log.murder.rate, na.rm = T)
  illinois.lag.whole[i] <- mean(cleaned.data[cleaned.data$State == s & cleaned.data$Year<=2010,]$log.murder.rate, na.rm = T)
  conn.lag.whole[i] <- mean(cleaned.data[cleaned.data$State == s & cleaned.data$Year<=2011,]$log.murder.rate, na.rm = T)
  nj.lag.whole[i] <- mean(cleaned.data[cleaned.data$State == s & cleaned.data$Year<=2006,]$log.murder.rate, na.rm = T)
  del.lag.whole[i] <- mean(cleaned.data[cleaned.data$State == s & cleaned.data$Year<=2015,]$log.murder.rate, na.rm = T)
  maryland.lag.whole[i] <- mean(cleaned.data[cleaned.data$State == s & cleaned.data$Year<=2012,]$log.murder.rate, na.rm = T)
  i <- i + 1
}

cleaned.data$ny.lag.whole <- rep(ny.lag.whole, each = 24)
cleaned.data$nm.lag.whole <- rep(nm.lag.whole, each = 24)
cleaned.data$illinois.lag.whole <- rep(illinois.lag.whole, each = 24)
cleaned.data$conn.lag.whole <- rep(conn.lag.whole, each = 24)
cleaned.data$nj.lag.whole <- rep(nj.lag.whole, each = 24)
cleaned.data$del.lag.whole <- rep(del.lag.whole, each = 24)
cleaned.data$maryland.lag.whole <- rep(maryland.lag.whole, each = 24)

death.set <- cleaned.data[(cleaned.data$State!="New York" & cleaned.data$State!="Maryland" & cleaned.data$State!="Delaware" & cleaned.data$State!="Illinois" & cleaned.data$State!="New Mexico" & cleaned.data$State!="Connecticut" & cleaned.data$State!="New Jersey"),]


death.set$number <- rep(1:29, each=24)

NY <- cleaned.data[cleaned.data$State=="New York",]
NY$number <- 36
NY.Set <- rbind(death.set, NY)

Maryland <- cleaned.data[cleaned.data$State=="Maryland",]
Maryland$number <- 37 
Maryland.Set <- rbind(death.set, Maryland)

Delaware <- cleaned.data[cleaned.data$State=="Delaware",]
Delaware$number <- 38
Delaware.Set <- rbind(death.set, Delaware)

Illinois <- cleaned.data[cleaned.data$State=="Illinois",]
Illinois$number <- 39
Illinois.Set <- rbind(death.set, Illinois)

NM <- cleaned.data[cleaned.data$State=="New Mexico",]
NM$number <- 40
NM.Set <- rbind(death.set, NM)

Conn <- cleaned.data[cleaned.data$State=="Connecticut",]
Conn$number <- 41
Conn.Set <- rbind(death.set, Conn)

NJ <- cleaned.data[cleaned.data$State=="New Jersey",]
NJ$number <- 42
NJ.Set <- rbind(death.set, NJ)

library("Synth")

```

```{r, include=F}
library(lfe)

diff.in.diff <- felm(log.murder.rate ~ Death.Penalty.Numeric + crime.rate + Unemployment.Rate + robbery.rate + pop.den.n + proportion.15.29 + gdp.per.n + inequality + poverty + police.direct.expen.pc|State + Year|0|State, data = cleaned.data)

stargazer(diff.in.diff, title="Table X: Panel Difference-in-Differences Model is Indeterminant", type = "latex", report = ('vc*s'), covariate.labels = c("Death Penalty Statute (1 = Yes, 0 = No)", "Property Crime Rate (Crimes Per Resident)", "Unemployment Rate (Percentage)", "Robberies Per Resident", "Population Density", "Proportion 15-29", "GDP Per Capita (2012 Dollars)", "Percentage of Income Held By Top 1 Percent", "Percentage in Poverty", "Direct Expenditures on Police Per Capita"), dep.var.labels = c("Logged Murder Rate"), column.separate = c(3,3), omit.stat = c("adj.rsq", "f", "ser"), style = "qje",  add.lines = list(c("State Fixed Effects", "Yes"), c("Year Fixed Effects", "Yes"), c("Standard Errors Clustered By Unit", "Yes")), notes.append = T, column.sep.width = c("-5pt"), notes.align = "l")


```

```{r, include=F}

library(gsynth)

cleaned.data$treated <- (cleaned.data$Death.Penalty.Numeric-1)*(-1)

cleaned.data.gsmc <- cleaned.data[cleaned.data$State!="New York",]

gsynth.object.one <- gsynth(log.murder.rate ~ treated + crime.rate + Unemployment.Rate + robbery.rate + pop.den.n + proportion.15.29+ gdp.per.n + poverty, index = c("State", "Year"), data = cleaned.data.gsmc, se = TRUE)



```


```{r, include=F}
### New York 

new.york.effect <- dataprep(foo = NY.Set, time.predictors.prior = c(1995:2004), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "ny.lag.1", "ny.lag.5", "ny.lag.9"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 36, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 

synth.out <- synth(data.prep.obj = new.york.effect, method = "All")

ny.tables <- synth.tab(dataprep.res = new.york.effect, synth.res = synth.out)

path.plot(synth.res = synth.out, dataprep.res = new.york.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004)

ny.gaps <- new.york.effect$Y1plot - (new.york.effect$Y0plot %*% synth.out$solution.w)


### New Mexico

nm.effect <- dataprep(foo = NM.Set, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nm.lag.1", "nm.lag.7", "nm.lag.14"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 40, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 

synth.out.2 <- synth(data.prep.obj = nm.effect, method = "All")

nm.tables <- synth.tab(dataprep.res = nm.effect, synth.res = synth.out.2)


path.plot(synth.res = synth.out.2, dataprep.res = nm.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009)

nm.gaps <- nm.effect$Y1plot - (nm.effect$Y0plot %*% synth.out.2$solution.w)


### Illinois 

Illinois.effect <- dataprep(foo = Illinois.Set, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "illinois.lag.1", "illinois.lag.8", "illinois.lag.16"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 39, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 

synth.out.3 <- synth(data.prep.obj = Illinois.effect, method = "All")

Illinois.tables <- synth.tab(dataprep.res = Illinois.effect, synth.res = synth.out.3)

path.plot(synth.res = synth.out.3, dataprep.res = Illinois.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011)

Illinois.gaps <- Illinois.effect$Y1plot - (Illinois.effect$Y0plot %*% synth.out.3$solution.w)


### Connecticut

Conn.effect <- dataprep(foo = Conn.Set, time.predictors.prior = c(1995:2012), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "conn.lag.1", "conn.lag.9", "conn.lag.17"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 41, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 

synth.out.4 <- synth(data.prep.obj = Conn.effect, method = "All")

Conn.tables <- synth.tab(dataprep.res = Conn.effect, synth.res = synth.out.4)

path.plot(synth.res = synth.out.4, dataprep.res = Conn.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012)

Conn.gaps <- Conn.effect$Y1plot - (Conn.effect$Y0plot %*% synth.out.4$solution.w)


### New Jersey

NJ.effect <- dataprep(foo = NJ.Set, time.predictors.prior = c(1995:2007), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nj.lag.1", "nj.lag.6", "nj.lag.12"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 42, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 

synth.out.5 <- synth(data.prep.obj = NJ.effect, method = "All")

NJ.tables <- synth.tab(dataprep.res = NJ.effect, synth.res = synth.out.5)

path.plot(synth.res = synth.out.5, dataprep.res = NJ.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007)

NJ.gaps <- NJ.effect$Y1plot - (NJ.effect$Y0plot %*% synth.out.5$solution.w)

### Delaware

Delaware.effect <- dataprep(foo = Delaware.Set, time.predictors.prior = c(1995:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "del.lag.1", "del.lag.11", "del.lag.21"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 38, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2016), time.plot = c(1995:2018)) 

synth.out.6 <- synth(data.prep.obj = Delaware.effect, method = "All")

Delaware.tables <- synth.tab(dataprep.res = Delaware.effect, synth.res = synth.out.6)


path.plot(synth.res = synth.out.6, dataprep.res = Delaware.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016)

Delaware.gaps <- Delaware.effect$Y1plot - (Delaware.effect$Y0plot %*% synth.out.6$solution.w)

### Maryland

Maryland.effect <- dataprep(foo = Maryland.Set, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "maryland.lag.1", "maryland.lag.9", "maryland.lag.18"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 37, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 

synth.out.7 <- synth(data.prep.obj = Maryland.effect, method = "All")

path.plot(synth.res = synth.out.7, dataprep.res = Maryland.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013)

Maryland.tables <- synth.tab(dataprep.res = Maryland.effect, synth.res = synth.out.7)

Maryland.gaps <- Maryland.effect$Y1plot - (Maryland.effect$Y0plot %*% synth.out.7$solution.w)



############### ############### ############### 
############### Single Plot ###############
############### ############### ############### 



### New York 

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))
path.plot(synth.res = synth.out, dataprep.res = new.york.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004, col = "red")

### New Mexico


path.plot(synth.res = synth.out.2, dataprep.res = nm.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009, col = "red")
mtext("Figure 1: Synthetic Control Plots for States That Eliminated Capital Punishment (y = Log Murders Per 100,000 Residents)", side = 3, line = 4, font = 2)

### Illinois 


path.plot(synth.res = synth.out.3, dataprep.res = Illinois.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011, col = "red")



### Connecticut


path.plot(synth.res = synth.out.4, dataprep.res = Conn.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012, col = "red")


### New Jersey


path.plot(synth.res = synth.out.5, dataprep.res = NJ.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007, col = "red")


### Delaware


path.plot(synth.res = synth.out.6, dataprep.res = Delaware.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016, col = "red")


### Maryland

path.plot(synth.res = synth.out.7, dataprep.res = Maryland.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013, col = "red")

legend.cols <- c("black", "black", "red")
names(legend.cols) <- c("Treated", "Synthetic Control", "Year Eliminated DP")
par(fig= c(0, 1, 0, 1), oma = c(0,0,0,0), mar = c(.5, .5, .5, .5), new=TRUE)
plot(0,0, type = "n", bty="n", xaxt ="n", yaxt="n")
legend("bottom", text.width=c(0.3,0.3,0.3), legend=names(legend.cols), col = legend.cols, lty = c(1,2,1), lwd = c(2.5, 2.5, 2.5), cex = .75, xpd = TRUE, horiz = F, inset = c(0,0,0), bty = "y", text.font = 2)

######### Predictor Values #########

big.table <- rbind(ny.tables$tab.pred, nm.tables$tab.pred, Illinois.tables$tab.pred, Conn.tables$tab.pred, NJ.tables$tab.pred, Delaware.tables$tab.pred, Maryland.tables$tab.pred)

predictor.names <- c("Property Crimes Rates", "Unemployment Rate (Percentage)", "Robbery Rate", "Population Density", "Proportion Aged 15 to 29", "Real GDP Per Capita (2012 Dollars)", "Percentage of Income Held By Top 1%", "Poverty Rate (Percentage in Poverty)", "Direct Police Expenditures Per Capita", "Murder Rate 2003", "Murder Rate 1999", "Murder Rate 1995", "Property Crimes Rates", "Unemployment Rate (Percentage)", "Robbery Rate", "Population Density", "Proportion Aged 15 to 29", "Real GDP Per Capita (2012 Dollars)", "Percentage of Income Held By Top 1%", "Poverty Rate (Percentage in Poverty)", "Direct Police Expenditures Per Capita", "Murder Rate 2008", "Murder Rate 2002", "Murder Rate 1995", "Property Crimes Rates", "Unemployment Rate (Percentage)", "Robbery Rate", "Population Density", "Proportion Aged 15 to 29", "Real GDP Per Capita (2012 Dollars)", "Poverty Rate (Percentage in Poverty)", "Direct Police Expenditures Per Capita", "Murder Rate 2010", "Murder Rate 2003", "Murder Rate 1995", "Property Crimes Rates", "Unemployment Rate (Percentage)", "Robbery Rate", "Population Density", "Proportion Aged 15 to 29", "Real GDP Per Capita (2012 Dollars)", "Poverty Rate (Percentage in Poverty)", "Direct Police Expenditures Per Capita", "Murder Rate 2011", "Murder Rate 2003", "Murder Rate 1995", "Property Crimes Rates", "Unemployment Rate (Percentage)", "Robbery Rate", "Population Density", "Proportion Aged 15 to 29", "Real GDP Per Capita (2012 Dollars)", "Percentage of Income Held By Top 1%", "Poverty Rate (Percentage in Poverty)", "Direct Police Expenditures Per Capita", "Murder Rate 2006", "Murder Rate 2001", "Murder Rate 1995", "Property Crimes Rates", "Unemployment Rate (Percentage)", "Robbery Rate", "Population Density", "Proportion Aged 15 to 29", "Real GDP Per Capita (2012 Dollars)", "Poverty Rate (Percentage in Poverty)", "Murder Rate 2015", "Murder Rate 2005", "Murder Rate 1995", "Property Crimes Rates", "Unemployment Rate (Percentage)", "Robbery Rate", "Population Density", "Proportion Aged 15 to 29", "Real GDP Per Capita (2012 Dollars)", "Poverty Rate (Percentage in Poverty)", "Direct Police Expenditures Per Capita", "Murder Rate 2012", "Murder Rate 2004", "Murder Rate 1995")


big.table <- as.data.frame(big.table)

big.table <- cbind(predictor.names, big.table[,1], big.table[,2], big.table[,3])

sum.stats.1 <- as.data.frame(big.table)



##### Weights (Table 2) #####

weight.table <- cbind(round(synth.out$solution.w, 2), round(synth.out.2$solution.w, 2), round(synth.out.3$solution.w, 2), round(synth.out.4$solution.w, 2), round(synth.out.5$solution.w, 2), round(synth.out.6$solution.w, 2), round(synth.out.7$solution.w, 2))

weights.table.final <- cbind(unique(death.set$State), weight.table)


weights.table.final <- as.data.frame(weights.table.final)


########################################
########## Figure 2 ##########
########################################



par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))
gaps.plot(synth.res = synth.out, dataprep.res = new.york.effect, Ylab = "", Xlab = "Year", Ylim = c(-1.5, 1.5), Main = "New York")
abline(v=2004, col = "red")


gaps.plot(synth.res = synth.out.2, dataprep.res = nm.effect, Ylab = "", Xlab = "Year", Ylim = c(-1.5, 1.5), Main = "New Mexico")
abline(v=2009, col = "red")
mtext("Figure 2: Gap Plots for States That Eliminated Capital Punishment (Y = Log Murder Rate Treated State - Log Murder Rate Synthetic Control)", side = 3, line = 4, font = 2)

gaps.plot(synth.res = synth.out.3, dataprep.res = Illinois.effect, Ylab = "", Xlab = "Year", Ylim = c(-1.5, 1.5), Main = "Illinois")
abline(v=2011, col = "red")

gaps.plot(synth.res = synth.out.4, dataprep.res = Conn.effect, Ylab = "", Xlab = "Year", Ylim = c(-1.5, 1.5), Main = "Connecticut")
abline(v=2012, col = "red")

gaps.plot(synth.res = synth.out.5, dataprep.res = NJ.effect, Ylab = "", Xlab = "Year", Ylim = c(-1.5, 1.5), Main = "New Jersey")
abline(v=2007, col = "red")

gaps.plot(synth.res = synth.out.6, dataprep.res = Delaware.effect, Ylab = "", Xlab = "Year", Ylim = c(-1.5, 1.5), Main = "Delaware")
abline(v=2016, col = "red")

gaps.plot(synth.res = synth.out.7, dataprep.res = Maryland.effect, Ylab = "", Xlab = "Year", Ylim = c(-1.5, 1.5), Main = "Maryland")
abline(v=2013, col = "red")

legend.cols <- c("black", "red")
names(legend.cols) <- c("Treated - Synthetic Control", "Year Eliminated DP")
par(fig= c(0, 1, 0, 1), oma = c(0,0,0,0), mar = c(.5, .5, .5, .5), new=TRUE)
plot(0,0, type = "n", bty="n", xaxt ="n", yaxt="n")
legend("bottom", text.width=c(0.3,0.3), legend=names(legend.cols), col = legend.cols, lty = c(1,1), lwd = c(2.5, 2.5), cex = .75, xpd = TRUE, horiz = F, inset = c(0,0), bty = "y", text.font = 2)

```


```{r, include=F}

########################################
###### Adding to Placebo Gap Analysis ############
########################################

#### NY Placebo Prep
ny.placebos <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.ny <- dataprep(foo = death.set, time.predictors.prior = c(1995:2004), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "ny.lag.1", "ny.lag.5", "ny.lag.9"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 
  synth.out.9 <- synth(data.prep.obj = death.set.effect.ny, method = "All")
  death.set.effect.ny.gaps <- death.set.effect.ny$Y1plot - (death.set.effect.ny$Y0plot %*% synth.out.9$solution.w);
  ny.placebos[,i] <- death.set.effect.ny.gaps
  i <- i + 1
}

final.ny <- cbind(ny.placebos, ny.gaps)
years <- seq(from=1995, to = 2018, by=1)

#### NM Placebo Prep
NM.placebos <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NM <- dataprep(foo = death.set, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nm.lag.1", "nm.lag.7", "nm.lag.14"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 
  synth.out.10 <- synth(data.prep.obj = death.set.effect.NM, method = "All")
  death.set.effect.nm.gaps <- death.set.effect.NM$Y1plot - (death.set.effect.NM$Y0plot %*% synth.out.10$solution.w);
  NM.placebos[,i] <- death.set.effect.nm.gaps
  i <- i + 1
}

final.NM <- cbind(NM.placebos, nm.gaps)
years <- seq(from=1995, to = 2018, by=1)


#### Illinois Placebo Prep
Illinois.placebos <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Illinois <- dataprep(foo = death.set, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "illinois.lag.1", "illinois.lag.8", "illinois.lag.16"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 
  synth.out.11 <- synth(data.prep.obj = death.set.effect.Illinois, method = "All")
  death.set.effect.Illinois.gaps <- death.set.effect.Illinois$Y1plot - (death.set.effect.Illinois$Y0plot %*% synth.out.11$solution.w);
  Illinois.placebos[,i] <- death.set.effect.Illinois.gaps
  i <- i + 1
}

final.Illinois <- cbind(Illinois.placebos, Illinois.gaps)
years <- seq(from=1995, to = 2018, by=1)


#### Conn Placebo Prep
Conn.placebos <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Conn <- dataprep(foo = death.set, time.predictors.prior = c(1995:2012), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "conn.lag.1", "conn.lag.9", "conn.lag.17"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 
  synth.out.12 <- synth(data.prep.obj = death.set.effect.Conn, method = "All")
  death.set.effect.Conn.gaps <- death.set.effect.Conn$Y1plot - (death.set.effect.Conn$Y0plot %*% synth.out.12$solution.w);
  Conn.placebos[,i] <- death.set.effect.Conn.gaps
  i <- i + 1
}

final.Conn <- cbind(Conn.placebos, Conn.gaps)
years <- seq(from=1995, to = 2018, by=1)


#### NJ Placebo Prep
NJ.placebos <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NJ <- dataprep(foo = death.set, time.predictors.prior = c(1995:2007), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nj.lag.1", "nj.lag.6", "nj.lag.12"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 
  synth.out.13 <- synth(data.prep.obj = death.set.effect.NJ, method = "All")
  death.set.effect.NJ.gaps <- death.set.effect.NJ$Y1plot - (death.set.effect.NJ$Y0plot %*% synth.out.13$solution.w);
  NJ.placebos[,i] <- death.set.effect.NJ.gaps
  i <- i + 1
}

final.NJ <- cbind(NJ.placebos, NJ.gaps)
years <- seq(from=1995, to = 2018, by=1)


#### Delaware Placebo Prep
Delaware.placebos <- matrix(nrow = 24, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Delaware <- dataprep(foo = death.set, time.predictors.prior = c(1995:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "del.lag.1", "del.lag.11", "del.lag.21"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2016), time.plot = c(1995:2018)) 
  synth.out.14 <- synth(data.prep.obj = death.set.effect.Delaware, method = "All")
  death.set.effect.Delaware.gaps <- death.set.effect.Delaware$Y1plot - (death.set.effect.Delaware$Y0plot %*% synth.out.14$solution.w);
  Delaware.placebos[,i] <- death.set.effect.Delaware.gaps
  i <- i + 1
}

final.Delaware <- cbind(Delaware.placebos, Delaware.gaps)
years <- seq(from=1995, to = 2018, by=1)

#### Maryland Placebo Prep


maryland.placebos <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
controls <- c(1:29)
controls.complete <- controls[controls!=s]
death.set.effect.maryland <- dataprep(foo = death.set, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "maryland.lag.1", "maryland.lag.9", "maryland.lag.18"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 
synth.out.8 <- synth(data.prep.obj = death.set.effect.maryland, method = "All")
death.set.maryland.gaps <- death.set.effect.maryland$Y1plot - (death.set.effect.maryland$Y0plot %*% synth.out.8$solution.w);
maryland.placebos[,i] <- death.set.maryland.gaps
i <- i + 1
}

maryland.placebos
final.maryland <- cbind(maryland.placebos, Maryland.gaps)
years <- seq(from=1995, to = 2018, by=1)


### All Plots in One

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))
black.red <- c(1:29, "purple")
plot.ts(final.ny, plot.type = "single", col = c(black.red), axes=F, xlab = "Year", ylab = "Difference Between Treated and Synthetic Control", lwd = c(rep(1, 29), 5), main = "New York Placebo Plot")
axis(2)
axis(1, labels = years, at = 1:24)
abline(h=0, lwd = 2, lty = 1, col = "blue")
abline(v = 10, lwd = 2, lty = 2, col = "red")
box()

black.red <- c(1:29, "purple")
plot.ts(final.NM, plot.type = "single", col = c(black.red), axes=F, xlab = "Year", ylab = "Difference Between Treated and Synthetic Control", lwd = c(rep(1, 29), 5), main = "New Mexico Placebo Plot")
axis(2)
axis(1, labels = years, at = 1:24)
abline(h=0, lwd = 2, lty = 1, col = "blue")
abline(v = 15, lwd = 2, lty = 2, col = "red")
box()
mtext("Figure 3: Placebo Gap Plots for States That Eliminated Capital Punishment (Y = Log Murder Rate Treated State - Log Murder Rate Synthetic Control)", side = 3, line = 4, font = 2)

black.red <- c(1:29, "purple")
plot.ts(final.Illinois, plot.type = "single", col = c(black.red), axes=F, xlab = "Year", ylab = "Difference Between Treated and Synthetic Control", lwd = c(rep(1, 29), 5), main = "Illinois Placebo Plot")
axis(2)
axis(1, labels = years, at = 1:24)
abline(h=0, lwd = 2, lty = 1, col = "blue")
abline(v = 17, lwd = 2, lty = 2, col = "red")
box()

black.red <- c(1:29, "purple")
plot.ts(final.Conn, plot.type = "single", col = c(black.red), axes=F, xlab = "Year", ylab = "Difference Between Treated and Synthetic Control", lwd = c(rep(1, 29), 5), main = "Connecticut Placebo Plot")
axis(2)
axis(1, labels = years, at = 1:24)
abline(h=0, lwd = 2, lty = 1, col = "blue")
abline(v = 18, lwd = 2, lty = 2, col = "red")
box()

black.red <- c(1:29, "purple")
plot.ts(final.NJ, plot.type = "single", col = c(black.red), axes=F, xlab = "Year", ylab = "Difference Between Treated and Synthetic Control", lwd = c(rep(1, 29), 5), main = "New Jersey Placebo Plot")
axis(2)
axis(1, labels = years, at = 1:24)
abline(h=0, lwd = 2, lty = 1, col = "blue")
abline(v = 13, lwd = 2, lty = 2, col = "red")
box()

black.red <- c(1:29, "purple")
plot.ts(final.Delaware, plot.type = "single", col = c(black.red), axes=F, xlab = "Year", ylab = "Difference Between Treated and Synthetic Control", lwd = c(rep(1, 29), 5), main = "Delaware Placebo Plot")
axis(2)
axis(1, labels = years, at = 1:24)
abline(h=0, lwd = 2, lty = 1, col = "blue")
abline(v = 22, lwd = 2, lty = 2, col = "red")
box()

black.red <- c(1:29, "purple")
plot.ts(final.maryland, plot.type = "single", col = c(black.red), axes=F, xlab = "Year", ylab = "Difference Between Treated and Synthetic Control", lwd = c(rep(1, 29), 5), main = "Maryland Placebo Plot")
axis(2)
axis(1, labels = years, at = 1:24)
abline(h=0, lwd = 2, lty = 1, col = "blue")
abline(v = 19, lwd = 2, lty = 2, col = "red")
box()

legend.cols <- c("yellow", "green", "pink", "purple", "red")
names(legend.cols) <- c("Placebo Difference-in-Differences", "Placebo Difference-in-Differences", "Placebo Difference-in-Differences", "Actual Difference-in-Differences", "Year Eliminated DP")
par(fig= c(0, 1, 0, 1), oma = c(0,0,0,0), mar = c(.5, .5, .5, .5), new=TRUE)
plot(0,0, type = "n", bty="n", xaxt ="n", yaxt="n")
legend("bottom", text.width=c(0.3,0.3,0.3), legend=names(legend.cols), col = legend.cols, lty = c(1,1,1,1,2), lwd = c(2.5, 2.5, 2.5, 5, 2.5), cex = .75, xpd = TRUE, horiz = F, inset = c(0,0,0), bty = "y", text.font = 2)

########################################
########## Permutation Calculations ##########
########################################

ny.pre.gaps <- final.ny[1:10,]
ny.post.gaps <- final.ny[11:nrow(final.ny),]

nm.pre.gaps <- final.NM[1:15,]
nm.post.gaps <- final.NM[16:nrow(final.NM),]

Illinois.pre.gaps <- final.Illinois[1:17,]
Illinois.post.gaps <- final.Illinois[18:nrow(final.Illinois),]

Conn.pre.gaps <- final.Conn[1:18,]
Conn.post.gaps <- final.Conn[19:nrow(final.Conn),]

NJ.pre.gaps <- final.NJ[1:13,]
NJ.post.gaps <- final.NJ[14:nrow(final.NJ),]

Delaware.pre.gaps <- final.Delaware[1:22,]
Delaware.post.gaps <- final.Delaware[23:nrow(final.Delaware),]

Maryland.pre.gaps <- final.maryland[1:19,]
Maryland.post.gaps <- final.maryland[20:nrow(final.maryland),]

diff.in.diff.ny <- colMeans(ny.post.gaps) - colMeans(ny.pre.gaps)
diff.in.diff.ny.placebo <- diff.in.diff.ny[1:(length(diff.in.diff.ny)-1)]
diff.in.diff.ny.actual <- diff.in.diff.ny[length(diff.in.diff.ny)]

diff.in.diff.nm <- colMeans(nm.post.gaps) - colMeans(nm.pre.gaps)
diff.in.diff.nm.placebo <- diff.in.diff.nm[1:(length(diff.in.diff.nm)-1)]
diff.in.diff.nm.actual <- diff.in.diff.nm[length(diff.in.diff.nm)]

diff.in.diff.Illinois <- colMeans(Illinois.post.gaps) - colMeans(Illinois.pre.gaps)
diff.in.diff.Illinois.placebo <- diff.in.diff.Illinois[1:(length(diff.in.diff.Illinois)-1)]
diff.in.diff.Illinois.actual <- diff.in.diff.Illinois[length(diff.in.diff.Illinois)]

diff.in.diff.Conn <- colMeans(Conn.post.gaps) - colMeans(Conn.pre.gaps)
diff.in.diff.Conn.placebo <- diff.in.diff.Conn[1:(length(diff.in.diff.Conn)-1)]
diff.in.diff.Conn.actual <- diff.in.diff.Conn[length(diff.in.diff.Conn)]

diff.in.diff.NJ <- colMeans(NJ.post.gaps) - colMeans(NJ.pre.gaps)
diff.in.diff.NJ.placebo <- diff.in.diff.NJ[1:(length(diff.in.diff.NJ)-1)]
diff.in.diff.NJ.actual <- diff.in.diff.NJ[length(diff.in.diff.NJ)]

diff.in.diff.Delaware <- colMeans(Delaware.post.gaps) - colMeans(Delaware.pre.gaps)
diff.in.diff.Delaware.placebo <- diff.in.diff.Delaware[1:(length(diff.in.diff.Delaware)-1)]
diff.in.diff.Delaware.actual <- diff.in.diff.Delaware[length(diff.in.diff.Delaware)]

diff.in.diff.Maryland <- colMeans(Maryland.post.gaps) - colMeans(Maryland.pre.gaps)
diff.in.diff.Maryland.placebo <- diff.in.diff.Maryland[1:(length(diff.in.diff.Maryland)-1)]
diff.in.diff.Maryland.actual <- diff.in.diff.Maryland[length(diff.in.diff.Maryland)]
  
exceeds.ny <- length(diff.in.diff.ny.placebo[diff.in.diff.ny.placebo>diff.in.diff.ny.actual])  
less.than.ny <- length(diff.in.diff.ny.placebo)-exceeds.ny

exceeds.nm <- length(diff.in.diff.nm.placebo[diff.in.diff.nm.placebo>diff.in.diff.nm.actual])  
less.than.nm <- length(diff.in.diff.nm.placebo)-exceeds.nm

exceeds.Illinois <- length(diff.in.diff.Illinois.placebo[diff.in.diff.Illinois.placebo>diff.in.diff.Illinois.actual])  
less.than.Illinois <- length(diff.in.diff.Illinois.placebo)-exceeds.Illinois

exceeds.Conn <- length(diff.in.diff.Conn.placebo[diff.in.diff.Conn.placebo>diff.in.diff.Conn.actual])  
less.than.Conn <- length(diff.in.diff.Conn.placebo)-exceeds.Conn

exceeds.NJ <- length(diff.in.diff.NJ.placebo[diff.in.diff.NJ.placebo>diff.in.diff.NJ.actual])  
less.than.NJ <- length(diff.in.diff.NJ.placebo)-exceeds.NJ

exceeds.Delaware <- length(diff.in.diff.Delaware.placebo[diff.in.diff.Delaware.placebo>diff.in.diff.Delaware.actual])  
less.than.Delaware <- length(diff.in.diff.Delaware.placebo)-exceeds.Delaware

exceeds.Maryland <- length(diff.in.diff.Maryland.placebo[diff.in.diff.Maryland.placebo>diff.in.diff.Maryland.actual])  
less.than.Maryland <- length(diff.in.diff.Maryland.placebo)-exceeds.Maryland

container.matrix <- matrix(nrow = 7, ncol = 5)
container.matrix[1,] <- c("New York", round(diff.in.diff.ny.actual, 2), exceeds.ny, less.than.ny, round((exceeds.ny/29), 2))
container.matrix[2,] <- c("New Mexico", round(diff.in.diff.nm.actual, 2), exceeds.nm, less.than.nm, round((exceeds.nm/29), 2))
container.matrix[3,] <- c("Illinois", round(diff.in.diff.Illinois.actual, 2), exceeds.Illinois, less.than.Illinois, round((exceeds.Illinois/29), 2))
container.matrix[4,] <- c("Connecticut", round(diff.in.diff.Conn.actual, 2), exceeds.Conn, less.than.Conn, round((exceeds.Conn/29), 2))
container.matrix[5,] <- c("New Jersey", round(diff.in.diff.NJ.actual, 2), exceeds.NJ, less.than.NJ, round((exceeds.NJ/29), 2))
container.matrix[6,] <- c("Delaware", round(diff.in.diff.Delaware.actual, 2), exceeds.Delaware, less.than.Delaware, round((exceeds.Delaware/29), 2))
container.matrix[7,] <- c("Maryland", round(diff.in.diff.Maryland.actual, 2), exceeds.Maryland, less.than.Maryland, round((exceeds.Maryland/29), 2))

sum.stats <- as.data.frame(container.matrix)

###### RMSPE Ratios

rmpse.ratios.ny <- sqrt(colMeans(ny.post.gaps^2))/sqrt(colMeans(ny.pre.gaps^2))

state.names.death.set <- unique(death.set$State)

names(rmpse.ratios.ny) <- c(state.names.death.set, "New York")
  
dotchart(sort(rmpse.ratios.ny),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 18), "red", rep("black", 11)))

rmpse.ratios.nm <- sqrt(colMeans(nm.post.gaps^2))/sqrt(colMeans(nm.pre.gaps^2))

names(rmpse.ratios.nm) <- c(state.names.death.set, "New Mexico")
  
dotchart(sort(rmpse.ratios.nm),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 18), "red", rep("black", 11)))

rmpse.ratios.Illinois <- sqrt(colMeans(Illinois.post.gaps^2))/sqrt(colMeans(Illinois.pre.gaps^2))

names(rmpse.ratios.Illinois) <- c(state.names.death.set, "Illinois")
  
dotchart(sort(rmpse.ratios.Illinois),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 21), "red", rep("black", 8)))


rmpse.ratios.Conn <- sqrt(colMeans(Conn.post.gaps^2))/sqrt(colMeans(Conn.pre.gaps^2))

names(rmpse.ratios.Conn) <- c(state.names.death.set, "Connecticut")
  
dotchart(sort(rmpse.ratios.Conn),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 22), "red", rep("black", 7)))


rmpse.ratios.NJ <- sqrt(colMeans(NJ.post.gaps^2))/sqrt(colMeans(NJ.pre.gaps^2))

names(rmpse.ratios.NJ) <- c(state.names.death.set, "New Jersey")
  
dotchart(sort(rmpse.ratios.NJ),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 11), "red", rep("black", 19)))


rmpse.ratios.Delaware <- sqrt(colMeans(Delaware.post.gaps^2))/sqrt(colMeans(Delaware.pre.gaps^2))

names(rmpse.ratios.Delaware) <- c(state.names.death.set, "Delaware")
  
dotchart(sort(rmpse.ratios.Delaware),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 5), "red", rep("black", 25)))


rmpse.ratios.Maryland <- sqrt(colMeans(Maryland.post.gaps^2))/sqrt(colMeans(Maryland.pre.gaps^2))

names(rmpse.ratios.Maryland) <- c(state.names.death.set, "Maryland")
  
dotchart(sort(rmpse.ratios.Maryland),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 23), "red", rep("black", 7)))


par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))

dotchart(sort(rmpse.ratios.ny),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 18), "red", rep("black", 11)), cex = .4)

dotchart(sort(rmpse.ratios.nm),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 18), "red", rep("black", 11)), cex = .4)

mtext("Figure X: Ratios of Post-Treatment RMSPE to Pre-Treatment RMSPE", side = 3, line = 4, font = 2)

dotchart(sort(rmpse.ratios.Illinois),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 21), "red", rep("black", 8)), cex = .4)

dotchart(sort(rmpse.ratios.Conn),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 22), "red", rep("black", 7)), cex = .4)

dotchart(sort(rmpse.ratios.NJ),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 11), "red", rep("black", 19)), cex = .4)

dotchart(sort(rmpse.ratios.Delaware),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 5), "red", rep("black", 25)), cex = .4)

dotchart(sort(rmpse.ratios.Maryland),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 23), "red", rep("black", 7)), cex = .4)

##################################################################################################################################################################################################################################################################################################################
##################################################################################################################################################################################################################################################################################################################
##################################################################################################################################################################################################################################################################################################################
##################################################################################################################################################################################################################################################################################################################
############## Robustness Check ######################################################################
######################################################################################################
##################################################################################################################################################################################################################################################################################################################
##################################################################################################################################################################################################################################################################################################################
##################################################################################################################################################################################################################################################################################################################
##################################################################################################################################################################################################################################################################################################################


########################################
##### Robust 1 (Anticipation) #########
########################################


### New York 

new.york.effect.robust <- dataprep(foo = NY.Set, time.predictors.prior = c(1995:2002), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "ny.lag.new.1", "ny.lag.new.5", "ny.lag.new.9"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 36, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2002), time.plot = c(1995:2015)) 

synth.out.robust <- synth(data.prep.obj = new.york.effect.robust, method = "All")

path.plot(synth.res = synth.out.robust, dataprep.res = new.york.effect.robust, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2002)

ny.gaps.robust <- new.york.effect.robust$Y1plot - (new.york.effect.robust$Y0plot %*% synth.out.robust$solution.w)


### New Mexico

nm.effect.robust <- dataprep(foo = NM.Set, time.predictors.prior = c(1995:2007), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nm.lag.new.1", "nm.lag.new.7", "nm.lag.new.14"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 40, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 

synth.out.2.robust <- synth(data.prep.obj = nm.effect.robust, method = "All")

path.plot(synth.res = synth.out.2.robust, dataprep.res = nm.effect.robust, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2007)

nm.gaps.robust <- nm.effect.robust$Y1plot - (nm.effect.robust$Y0plot %*% synth.out.2.robust$solution.w)


### Illinois 

Illinois.effect.robust <- dataprep(foo = Illinois.Set, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "illinois.lag.new.1", "illinois.lag.new.8", "illinois.lag.new.16"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 39, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2017)) 

synth.out.3.robust <- synth(data.prep.obj = Illinois.effect.robust, method = "All")

path.plot(synth.res = synth.out.3.robust, dataprep.res = Illinois.effect.robust, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2009)

Illinois.gaps.robust <- Illinois.effect.robust$Y1plot - (Illinois.effect.robust$Y0plot %*% synth.out.3.robust$solution.w)


### Connecticut

Conn.effect.robust <- dataprep(foo = Conn.Set, time.predictors.prior = c(1995:2010), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "conn.lag.new.1", "conn.lag.new.9", "conn.lag.new.17"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 41, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2010), time.plot = c(1995:2017)) 

synth.out.4.robust <- synth(data.prep.obj = Conn.effect.robust, method = "All")

path.plot(synth.res = synth.out.4.robust, dataprep.res = Conn.effect.robust, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2010)

Conn.gaps.robust <- Conn.effect.robust$Y1plot - (Conn.effect.robust$Y0plot %*% synth.out.4.robust$solution.w)


### New Jersey

NJ.effect.robust <- dataprep(foo = NJ.Set, time.predictors.prior = c(1995:2005), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nj.lag.new.1", "nj.lag.new.6", "nj.lag.new.12"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 42, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2005), time.plot = c(1995:2015)) 

synth.out.5.robust <- synth(data.prep.obj = NJ.effect.robust, method = "All")

path.plot(synth.res = synth.out.5.robust, dataprep.res = NJ.effect.robust, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2005)

NJ.gaps.robust <- NJ.effect.robust$Y1plot - (NJ.effect.robust$Y0plot %*% synth.out.5.robust$solution.w)

### Delaware

Delaware.effect.robust <- dataprep(foo = Delaware.Set, time.predictors.prior = c(1995:2014), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "del.lag.new.1", "del.lag.new.11", "del.lag.new.21"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 38, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2014), time.plot = c(1995:2018)) 

synth.out.6.robust <- synth(data.prep.obj = Delaware.effect.robust, method = "All")

path.plot(synth.res = synth.out.6.robust, dataprep.res = Delaware.effect.robust, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2014)

Delaware.gaps.robust <- Delaware.effect.robust$Y1plot - (Delaware.effect.robust$Y0plot %*% synth.out.6.robust$solution.w)

### Maryland

Maryland.effect.robust <- dataprep(foo = Maryland.Set, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "maryland.lag.new.1", "maryland.lag.new.9", "maryland.lag.new.18"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 37, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 

synth.out.7.robust <- synth(data.prep.obj = Maryland.effect.robust, method = "All")

path.plot(synth.res = synth.out.7.robust, dataprep.res = Maryland.effect.robust, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2011)

maryland.tables.robust <- synth.tab(dataprep.res = Maryland.effect.robust, synth.res = synth.out.7.robust)

maryland.tables.robust$tab.pred

Maryland.gaps.robust <- Maryland.effect.robust$Y1plot - (Maryland.effect.robust$Y0plot %*% synth.out.7.robust$solution.w)



############### ############### ############### 
############### Single Plot ###############
############### ############### ############### 



### New York 

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))
path.plot(synth.res = synth.out.robust, dataprep.res = new.york.effect.robust, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2002, col = "red")

### New Mexico


path.plot(synth.res = synth.out.2.robust, dataprep.res = nm.effect.robust, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2007, col = "red")
mtext("Figure 4: Testing for Anticipation Effects (y = Log Murders Per 100,000 Residents)", side = 3, line = 4, font = 2)

### Illinois 


path.plot(synth.res = synth.out.3.robust, dataprep.res = Illinois.effect.robust, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2009, col = "red")



### Connecticut


path.plot(synth.res = synth.out.4.robust, dataprep.res = Conn.effect.robust, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2010, col = "red")


### New Jersey


path.plot(synth.res = synth.out.5.robust, dataprep.res = NJ.effect.robust, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2005, col = "red")


### Delaware


path.plot(synth.res = synth.out.6.robust, dataprep.res = Delaware.effect.robust, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2014, col = "red")


### Maryland

path.plot(synth.res = synth.out.7.robust, dataprep.res = Maryland.effect.robust, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2011, col = "red")

legend.cols <- c("black", "black", "red")
names(legend.cols) <- c("Treated", "Synthetic Control", "Two Years Prior to DP Elimination")
par(fig= c(0, 1, 0, 1), oma = c(0,0,0,0), mar = c(.5, .5, .5, .5), new=TRUE)
plot(0,0, type = "n", bty="n", xaxt ="n", yaxt="n")
legend("bottom", text.width=c(0.3,0.3,0.3), legend=names(legend.cols), col = legend.cols, lty = c(1,2,1), lwd = c(2.5, 2.5, 2.5), cex = .75, xpd = TRUE, horiz = F, inset = c(0,0,0), bty = "y", text.font = 2)



########################################
###### Adding to Placebo Gap Analysis ############
########################################

#### NY Placebo Prep
ny.placebos.robust <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.ny.robust <- dataprep(foo = death.set, time.predictors.prior = c(1995:2002), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "ny.lag.new.1", "ny.lag.new.5", "ny.lag.new.9"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2002), time.plot = c(1995:2015)) 
  synth.out.9.robust <- synth(data.prep.obj = death.set.effect.ny.robust, method = "All")
  death.set.effect.ny.gaps.robust <- death.set.effect.ny.robust$Y1plot - (death.set.effect.ny.robust$Y0plot %*% synth.out.9.robust$solution.w);
  ny.placebos.robust[,i] <- death.set.effect.ny.gaps.robust
  i <- i + 1
}

final.ny.robust <- cbind(ny.placebos.robust, ny.gaps.robust)
years <- seq(from=1995, to = 2018, by=1)

#### NM Placebo Prep
NM.placebos.robust <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NM.robust <- dataprep(foo = death.set, time.predictors.prior = c(1995:2007), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nm.lag.new.1", "nm.lag.new.7", "nm.lag.new.14"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 
  synth.out.10.robust <- synth(data.prep.obj = death.set.effect.NM.robust, method = "All")
  death.set.effect.nm.gaps.robust <- death.set.effect.NM.robust$Y1plot - (death.set.effect.NM.robust$Y0plot %*% synth.out.10.robust$solution.w);
  NM.placebos.robust[,i] <- death.set.effect.nm.gaps.robust
  i <- i + 1
}

final.NM.robust <- cbind(NM.placebos.robust, nm.gaps.robust)
years <- seq(from=1995, to = 2018, by=1)


#### Illinois Placebo Prep
Illinois.placebos.robust <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Illinois.robust <- dataprep(foo = death.set, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "illinois.lag.new.1", "illinois.lag.new.8", "illinois.lag.new.16"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2017)) 
  synth.out.11.robust <- synth(data.prep.obj = death.set.effect.Illinois.robust, method = "All")
  death.set.effect.Illinois.gaps.robust <- death.set.effect.Illinois.robust$Y1plot - (death.set.effect.Illinois.robust$Y0plot %*% synth.out.11.robust$solution.w);
  Illinois.placebos.robust[,i] <- death.set.effect.Illinois.gaps.robust
  i <- i + 1
}

final.Illinois.robust <- cbind(Illinois.placebos.robust, Illinois.gaps.robust)
years <- seq(from=1995, to = 2018, by=1)


#### Conn Placebo Prep
Conn.placebos.robust <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Conn.robust <- dataprep(foo = death.set, time.predictors.prior = c(1995:2010), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "conn.lag.new.1", "conn.lag.new.9", "conn.lag.new.17"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2010), time.plot = c(1995:2017)) 
  synth.out.12.robust <- synth(data.prep.obj = death.set.effect.Conn.robust, method = "All")
  death.set.effect.Conn.gaps.robust <- death.set.effect.Conn.robust$Y1plot - (death.set.effect.Conn.robust$Y0plot %*% synth.out.12.robust$solution.w);
  Conn.placebos.robust[,i] <- death.set.effect.Conn.gaps.robust
  i <- i + 1
}

final.Conn.robust <- cbind(Conn.placebos.robust, Conn.gaps.robust)
years <- seq(from=1995, to = 2018, by=1)


#### NJ Placebo Prep
NJ.placebos.robust <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NJ.robust <- dataprep(foo = death.set, time.predictors.prior = c(1995:2005), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nj.lag.new.1", "nj.lag.new.6", "nj.lag.new.12"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2005), time.plot = c(1995:2015)) 
  synth.out.13.robust <- synth(data.prep.obj = death.set.effect.NJ.robust, method = "All")
  death.set.effect.NJ.gaps.robust <- death.set.effect.NJ.robust$Y1plot - (death.set.effect.NJ.robust$Y0plot %*% synth.out.13.robust$solution.w);
  NJ.placebos.robust[,i] <- death.set.effect.NJ.gaps.robust
  i <- i + 1
}

final.NJ.robust <- cbind(NJ.placebos.robust, NJ.gaps.robust)
years <- seq(from=1995, to = 2018, by=1)


#### Delaware Placebo Prep
Delaware.placebos.robust <- matrix(nrow = 24, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Delaware.robust <- dataprep(foo = death.set, time.predictors.prior = c(1995:2014), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "del.lag.new.1", "del.lag.new.11", "del.lag.new.21"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2014), time.plot = c(1995:2018)) 
  synth.out.14.robust <- synth(data.prep.obj = death.set.effect.Delaware.robust, method = "All")
  death.set.effect.Delaware.gaps.robust <- death.set.effect.Delaware.robust$Y1plot - (death.set.effect.Delaware.robust$Y0plot %*% synth.out.14.robust$solution.w);
  Delaware.placebos.robust[,i] <- death.set.effect.Delaware.gaps.robust
  i <- i + 1
}

final.Delaware.robust <- cbind(Delaware.placebos.robust, Delaware.gaps.robust)
years <- seq(from=1995, to = 2018, by=1)

#### Maryland Placebo Prep


maryland.placebos.robust <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.maryland.robust <- dataprep(foo = death.set, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "maryland.lag.new.1", "maryland.lag.new.9", "maryland.lag.new.18"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 
  synth.out.8.robust <- synth(data.prep.obj = death.set.effect.maryland.robust, method = "All")
  death.set.maryland.gaps.robust <- death.set.effect.maryland.robust$Y1plot - (death.set.effect.maryland.robust$Y0plot %*% synth.out.8.robust$solution.w);
  maryland.placebos.robust[,i] <- death.set.maryland.gaps.robust
  i <- i + 1
}

maryland.placebos.robust
final.maryland.robust <- cbind(maryland.placebos.robust, Maryland.gaps.robust)
years <- seq(from=1995, to = 2018, by=1)



########################################
########## Permutation Calculations ##########
########################################

ny.pre.gaps.robust <- final.ny.robust[1:8,]
ny.post.gaps.robust <- final.ny.robust[9:nrow(final.ny.robust),]

nm.pre.gaps.robust <- final.NM.robust[1:13,]
nm.post.gaps.robust <- final.NM.robust[14:nrow(final.NM.robust),]

Illinois.pre.gaps.robust <- final.Illinois.robust[1:15,]
Illinois.post.gaps.robust <- final.Illinois.robust[16:nrow(final.Illinois.robust),]

Conn.pre.gaps.robust <- final.Conn.robust[1:16,]
Conn.post.gaps.robust <- final.Conn.robust[17:nrow(final.Conn.robust),]

NJ.pre.gaps.robust <- final.NJ.robust[1:11,]
NJ.post.gaps.robust <- final.NJ.robust[12:nrow(final.NJ.robust),]

Delaware.pre.gaps.robust <- final.Delaware.robust[1:20,]
Delaware.post.gaps.robust <- final.Delaware.robust[21:nrow(final.Delaware.robust),]

Maryland.pre.gaps.robust <- final.maryland.robust[1:17,]
Maryland.post.gaps.robust <- final.maryland.robust[18:nrow(final.maryland.robust),]

diff.in.diff.ny.robust <- colMeans(ny.post.gaps.robust) - colMeans(ny.pre.gaps.robust)
diff.in.diff.ny.placebo.robust <- diff.in.diff.ny.robust[1:(length(diff.in.diff.ny.robust)-1)]
diff.in.diff.ny.actual.robust <- diff.in.diff.ny.robust[length(diff.in.diff.ny.robust)]

diff.in.diff.nm.robust <- colMeans(nm.post.gaps.robust) - colMeans(nm.pre.gaps.robust)
diff.in.diff.nm.placebo.robust <- diff.in.diff.nm.robust[1:(length(diff.in.diff.nm.robust)-1)]
diff.in.diff.nm.actual.robust <- diff.in.diff.nm.robust[length(diff.in.diff.nm.robust)]

diff.in.diff.Illinois.robust <- colMeans(Illinois.post.gaps.robust) - colMeans(Illinois.pre.gaps.robust)
diff.in.diff.Illinois.placebo.robust <- diff.in.diff.Illinois.robust[1:(length(diff.in.diff.Illinois.robust)-1)]
diff.in.diff.Illinois.actual.robust <- diff.in.diff.Illinois.robust[length(diff.in.diff.Illinois.robust)]

diff.in.diff.Conn.robust <- colMeans(Conn.post.gaps.robust) - colMeans(Conn.pre.gaps.robust)
diff.in.diff.Conn.placebo.robust <- diff.in.diff.Conn.robust[1:(length(diff.in.diff.Conn.robust)-1)]
diff.in.diff.Conn.actual.robust <- diff.in.diff.Conn.robust[length(diff.in.diff.Conn.robust)]

diff.in.diff.NJ.robust <- colMeans(NJ.post.gaps.robust) - colMeans(NJ.pre.gaps.robust)
diff.in.diff.NJ.placebo.robust <- diff.in.diff.NJ.robust[1:(length(diff.in.diff.NJ.robust)-1)]
diff.in.diff.NJ.actual.robust <- diff.in.diff.NJ.robust[length(diff.in.diff.NJ.robust)]

diff.in.diff.Delaware.robust <- colMeans(Delaware.post.gaps.robust) - colMeans(Delaware.pre.gaps.robust)
diff.in.diff.Delaware.placebo.robust <- diff.in.diff.Delaware.robust[1:(length(diff.in.diff.Delaware.robust)-1)]
diff.in.diff.Delaware.actual.robust <- diff.in.diff.Delaware.robust[length(diff.in.diff.Delaware.robust)]

diff.in.diff.Maryland.robust <- colMeans(Maryland.post.gaps.robust) - colMeans(Maryland.pre.gaps.robust)
diff.in.diff.Maryland.placebo.robust <- diff.in.diff.Maryland.robust[1:(length(diff.in.diff.Maryland.robust)-1)]
diff.in.diff.Maryland.actual.robust <- diff.in.diff.Maryland.robust[length(diff.in.diff.Maryland.robust)]

exceeds.ny.robust <- length(diff.in.diff.ny.placebo.robust[diff.in.diff.ny.placebo.robust>diff.in.diff.ny.actual.robust])  
less.than.ny.robust <- length(diff.in.diff.ny.placebo.robust)-exceeds.ny.robust

exceeds.nm.robust <- length(diff.in.diff.nm.placebo.robust[diff.in.diff.nm.placebo.robust>diff.in.diff.nm.actual.robust])  
less.than.nm.robust <- length(diff.in.diff.nm.placebo.robust)-exceeds.nm.robust

exceeds.Illinois.robust <- length(diff.in.diff.Illinois.placebo.robust[diff.in.diff.Illinois.placebo.robust>diff.in.diff.Illinois.actual.robust])  
less.than.Illinois.robust <- length(diff.in.diff.Illinois.placebo.robust)-exceeds.Illinois.robust

exceeds.Conn.robust <- length(diff.in.diff.Conn.placebo.robust[diff.in.diff.Conn.placebo.robust>diff.in.diff.Conn.actual.robust])  
less.than.Conn.robust <- length(diff.in.diff.Conn.placebo.robust)-exceeds.Conn.robust

exceeds.NJ.robust <- length(diff.in.diff.NJ.placebo.robust[diff.in.diff.NJ.placebo.robust>diff.in.diff.NJ.actual.robust])  
less.than.NJ.robust <- length(diff.in.diff.NJ.placebo.robust)-exceeds.NJ.robust

exceeds.Delaware.robust <- length(diff.in.diff.Delaware.placebo.robust[diff.in.diff.Delaware.placebo.robust>diff.in.diff.Delaware.actual.robust])  
less.than.Delaware.robust <- length(diff.in.diff.Delaware.placebo.robust)-exceeds.Delaware.robust

exceeds.Maryland.robust <- length(diff.in.diff.Maryland.placebo.robust[diff.in.diff.Maryland.placebo.robust>diff.in.diff.Maryland.actual.robust])  
less.than.Maryland.robust <- length(diff.in.diff.Maryland.placebo.robust)-exceeds.Maryland.robust

container.matrix.robust <- matrix(nrow = 7, ncol = 5)
container.matrix.robust[1,] <- c("New York", round(diff.in.diff.ny.actual.robust, 2), exceeds.ny.robust, less.than.ny.robust, round((exceeds.ny.robust/29), 2))
container.matrix.robust[2,] <- c("New Mexico", round(diff.in.diff.nm.actual.robust, 2), exceeds.nm.robust, less.than.nm.robust, round((exceeds.nm.robust/29), 2))
container.matrix.robust[3,] <- c("Illinois", round(diff.in.diff.Illinois.actual.robust, 2), exceeds.Illinois.robust, less.than.Illinois.robust, round((exceeds.Illinois.robust/29), 2))
container.matrix.robust[4,] <- c("Connecticut", round(diff.in.diff.Conn.actual.robust, 2), exceeds.Conn.robust, less.than.Conn.robust, round((exceeds.Conn.robust/29), 2))
container.matrix.robust[5,] <- c("New Jersey", round(diff.in.diff.NJ.actual.robust, 2), exceeds.NJ.robust, less.than.NJ.robust, round((exceeds.NJ.robust/29), 2))
container.matrix.robust[6,] <- c("Delaware", round(diff.in.diff.Delaware.actual.robust, 2), exceeds.Delaware.robust, less.than.Delaware.robust, round((exceeds.Delaware.robust/29), 2))
container.matrix.robust[7,] <- c("Maryland", round(diff.in.diff.Maryland.actual.robust, 2), exceeds.Maryland.robust, less.than.Maryland.robust, round((exceeds.Maryland.robust/29), 2))

sum.stats.robust <- as.data.frame(container.matrix.robust)




########################################
##### Robust 2 (No Lags) #########
########################################

### New York 

new.york.effect.robust.2 <- dataprep(foo = NY.Set, time.predictors.prior = c(1995:2004), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 36, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 

synth.out.robust.2 <- synth(data.prep.obj = new.york.effect.robust.2, method = "All")

path.plot(synth.res = synth.out.robust.2, dataprep.res = new.york.effect.robust.2, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004)

ny.gaps.robust.2 <- new.york.effect.robust.2$Y1plot - (new.york.effect.robust.2$Y0plot %*% synth.out.robust.2$solution.w)


### New Mexico

nm.effect.robust.2 <- dataprep(foo = NM.Set, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 40, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 

synth.out.2.robust.2 <- synth(data.prep.obj = nm.effect.robust.2, method = "All")

path.plot(synth.res = synth.out.2.robust.2, dataprep.res = nm.effect.robust.2, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009)

nm.gaps.robust.2 <- nm.effect.robust.2$Y1plot - (nm.effect.robust.2$Y0plot %*% synth.out.2.robust.2$solution.w)


### Illinois 

Illinois.effect.robust.2 <- dataprep(foo = Illinois.Set, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 39, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 

synth.out.3.robust.2 <- synth(data.prep.obj = Illinois.effect.robust.2, method = "All")

path.plot(synth.res = synth.out.3.robust.2, dataprep.res = Illinois.effect.robust.2, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011)

Illinois.gaps.robust.2 <- Illinois.effect.robust.2$Y1plot - (Illinois.effect.robust.2$Y0plot %*% synth.out.3.robust.2$solution.w)


### Connecticut

Conn.effect.robust.2 <- dataprep(foo = Conn.Set, time.predictors.prior = c(1995:2012), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 41, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 

synth.out.4.robust.2 <- synth(data.prep.obj = Conn.effect.robust.2, method = "All")

path.plot(synth.res = synth.out.4.robust.2, dataprep.res = Conn.effect.robust.2, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012)

Conn.gaps.robust.2 <- Conn.effect.robust.2$Y1plot - (Conn.effect.robust.2$Y0plot %*% synth.out.4.robust.2$solution.w)


### New Jersey

NJ.effect.robust.2 <- dataprep(foo = NJ.Set, time.predictors.prior = c(1995:2007), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 42, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 

synth.out.5.robust.2 <- synth(data.prep.obj = NJ.effect.robust.2, method = "All")

path.plot(synth.res = synth.out.5.robust.2, dataprep.res = NJ.effect.robust.2, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007)

NJ.gaps.robust.2 <- NJ.effect.robust.2$Y1plot - (NJ.effect.robust.2$Y0plot %*% synth.out.5.robust.2$solution.w)

### Delaware

Delaware.effect.robust.2 <- dataprep(foo = Delaware.Set, time.predictors.prior = c(1995:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 38, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2016), time.plot = c(1995:2018)) 

synth.out.6.robust.2 <- synth(data.prep.obj = Delaware.effect.robust.2, method = "All")

path.plot(synth.res = synth.out.6.robust.2, dataprep.res = Delaware.effect.robust.2, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016)

Delaware.gaps.robust.2 <- Delaware.effect.robust.2$Y1plot - (Delaware.effect.robust.2$Y0plot %*% synth.out.6.robust.2$solution.w)

### Maryland

Maryland.effect.robust.2 <- dataprep(foo = Maryland.Set, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 37, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 

synth.out.7.robust.2 <- synth(data.prep.obj = Maryland.effect.robust.2, method = "All")

path.plot(synth.res = synth.out.7.robust.2, dataprep.res = Maryland.effect.robust.2, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013)

maryland.tables.robust.2 <- synth.tab(dataprep.res = Maryland.effect.robust.2, synth.res = synth.out.7.robust.2)

maryland.tables.robust.2$tab.pred

Maryland.gaps.robust.2 <- Maryland.effect.robust.2$Y1plot - (Maryland.effect.robust.2$Y0plot %*% synth.out.7.robust.2$solution.w)




########################################
###### Adding to Placebo Gap Analysis ############
########################################

#### NY Placebo Prep
ny.placebos.robust.2 <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.ny.robust.2 <- dataprep(foo = death.set, time.predictors.prior = c(1995:2004), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 
  synth.out.9.robust.2 <- synth(data.prep.obj = death.set.effect.ny.robust.2, method = "All")
  death.set.effect.ny.gaps.robust.2 <- death.set.effect.ny.robust.2$Y1plot - (death.set.effect.ny.robust.2$Y0plot %*% synth.out.9.robust.2$solution.w);
  ny.placebos.robust.2[,i] <- death.set.effect.ny.gaps.robust.2
  i <- i + 1
}

final.ny.robust.2 <- cbind(ny.placebos.robust.2, ny.gaps.robust.2)
years <- seq(from=1995, to = 2018, by=1)

#### NM Placebo Prep
NM.placebos.robust.2 <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NM.robust.2 <- dataprep(foo = death.set, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 
  synth.out.10.robust.2 <- synth(data.prep.obj = death.set.effect.NM.robust.2, method = "All")
  death.set.effect.nm.gaps.robust.2 <- death.set.effect.NM.robust.2$Y1plot - (death.set.effect.NM.robust.2$Y0plot %*% synth.out.10.robust.2$solution.w);
  NM.placebos.robust.2[,i] <- death.set.effect.nm.gaps.robust.2
  i <- i + 1
}

final.NM.robust.2 <- cbind(NM.placebos.robust.2, nm.gaps.robust.2)
years <- seq(from=1995, to = 2018, by=1)


#### Illinois Placebo Prep
Illinois.placebos.robust.2 <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Illinois.robust.2 <- dataprep(foo = death.set, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 
  synth.out.11.robust.2 <- synth(data.prep.obj = death.set.effect.Illinois.robust.2, method = "All")
  death.set.effect.Illinois.gaps.robust.2 <- death.set.effect.Illinois.robust.2$Y1plot - (death.set.effect.Illinois.robust.2$Y0plot %*% synth.out.11.robust.2$solution.w);
  Illinois.placebos.robust.2[,i] <- death.set.effect.Illinois.gaps.robust.2
  i <- i + 1
}

final.Illinois.robust.2 <- cbind(Illinois.placebos.robust.2, Illinois.gaps.robust.2)
years <- seq(from=1995, to = 2018, by=1)


#### Conn Placebo Prep
Conn.placebos.robust.2 <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Conn.robust.2 <- dataprep(foo = death.set, time.predictors.prior = c(1995:2012), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 
  synth.out.12.robust.2 <- synth(data.prep.obj = death.set.effect.Conn.robust.2, method = "All")
  death.set.effect.Conn.gaps.robust.2 <- death.set.effect.Conn.robust.2$Y1plot - (death.set.effect.Conn.robust.2$Y0plot %*% synth.out.12.robust.2$solution.w);
  Conn.placebos.robust.2[,i] <- death.set.effect.Conn.gaps.robust.2
  i <- i + 1
}

final.Conn.robust.2 <- cbind(Conn.placebos.robust.2, Conn.gaps.robust.2)
years <- seq(from=1995, to = 2018, by=1)


#### NJ Placebo Prep
NJ.placebos.robust.2 <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NJ.robust.2 <- dataprep(foo = death.set, time.predictors.prior = c(1995:2007), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 
  synth.out.13.robust.2 <- synth(data.prep.obj = death.set.effect.NJ.robust.2, method = "All")
  death.set.effect.NJ.gaps.robust.2 <- death.set.effect.NJ.robust.2$Y1plot - (death.set.effect.NJ.robust.2$Y0plot %*% synth.out.13.robust.2$solution.w);
  NJ.placebos.robust.2[,i] <- death.set.effect.NJ.gaps.robust.2
  i <- i + 1
}

final.NJ.robust.2 <- cbind(NJ.placebos.robust.2, NJ.gaps.robust.2)
years <- seq(from=1995, to = 2018, by=1)


#### Delaware Placebo Prep
Delaware.placebos.robust.2 <- matrix(nrow = 24, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Delaware.robust.2 <- dataprep(foo = death.set, time.predictors.prior = c(1995:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2016), time.plot = c(1995:2018)) 
  synth.out.14.robust.2 <- synth(data.prep.obj = death.set.effect.Delaware.robust.2, method = "All")
  death.set.effect.Delaware.gaps.robust.2 <- death.set.effect.Delaware.robust.2$Y1plot - (death.set.effect.Delaware.robust.2$Y0plot %*% synth.out.14.robust.2$solution.w);
  Delaware.placebos.robust.2[,i] <- death.set.effect.Delaware.gaps.robust.2
  i <- i + 1
}

final.Delaware.robust.2 <- cbind(Delaware.placebos.robust.2, Delaware.gaps.robust.2)
years <- seq(from=1995, to = 2018, by=1)

#### Maryland Placebo Prep


maryland.placebos.robust.2 <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.maryland.robust.2 <- dataprep(foo = death.set, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 
  synth.out.8.robust.2 <- synth(data.prep.obj = death.set.effect.maryland.robust.2, method = "All")
  death.set.maryland.gaps.robust.2 <- death.set.effect.maryland.robust.2$Y1plot - (death.set.effect.maryland.robust.2$Y0plot %*% synth.out.8.robust.2$solution.w);
  maryland.placebos.robust.2[,i] <- death.set.maryland.gaps.robust.2
  i <- i + 1
}

maryland.placebos.robust.2
final.maryland.robust.2 <- cbind(maryland.placebos.robust.2, Maryland.gaps.robust.2)
years <- seq(from=1995, to = 2018, by=1)



########################################
########## Permutation Calculations ##########
########################################

ny.pre.gaps.robust.2 <- final.ny.robust.2[1:10,]
ny.post.gaps.robust.2 <- final.ny.robust.2[10:nrow(final.ny.robust.2),]

nm.pre.gaps.robust.2 <- final.NM.robust.2[1:15,]
nm.post.gaps.robust.2 <- final.NM.robust.2[16:nrow(final.NM.robust.2),]

Illinois.pre.gaps.robust.2 <- final.Illinois.robust.2[1:17,]
Illinois.post.gaps.robust.2 <- final.Illinois.robust.2[18:nrow(final.Illinois.robust.2),]

Conn.pre.gaps.robust.2 <- final.Conn.robust.2[1:18,]
Conn.post.gaps.robust.2 <- final.Conn.robust.2[19:nrow(final.Conn.robust.2),]

NJ.pre.gaps.robust.2 <- final.NJ.robust.2[1:13,]
NJ.post.gaps.robust.2 <- final.NJ.robust.2[14:nrow(final.NJ.robust.2),]

Delaware.pre.gaps.robust.2 <- final.Delaware.robust.2[1:22,]
Delaware.post.gaps.robust.2 <- final.Delaware.robust.2[23:nrow(final.Delaware.robust.2),]

Maryland.pre.gaps.robust.2 <- final.maryland.robust.2[1:19,]
Maryland.post.gaps.robust.2 <- final.maryland.robust.2[20:nrow(final.maryland.robust.2),]

diff.in.diff.ny.robust.2 <- colMeans(ny.post.gaps.robust.2) - colMeans(ny.pre.gaps.robust.2)
diff.in.diff.ny.placebo.robust.2 <- diff.in.diff.ny.robust.2[1:(length(diff.in.diff.ny.robust.2)-1)]
diff.in.diff.ny.actual.robust.2 <- diff.in.diff.ny.robust.2[length(diff.in.diff.ny.robust.2)]

diff.in.diff.nm.robust.2 <- colMeans(nm.post.gaps.robust.2) - colMeans(nm.pre.gaps.robust.2)
diff.in.diff.nm.placebo.robust.2 <- diff.in.diff.nm.robust.2[1:(length(diff.in.diff.nm.robust.2)-1)]
diff.in.diff.nm.actual.robust.2 <- diff.in.diff.nm.robust.2[length(diff.in.diff.nm.robust.2)]

diff.in.diff.Illinois.robust.2 <- colMeans(Illinois.post.gaps.robust.2) - colMeans(Illinois.pre.gaps.robust.2)
diff.in.diff.Illinois.placebo.robust.2 <- diff.in.diff.Illinois.robust.2[1:(length(diff.in.diff.Illinois.robust.2)-1)]
diff.in.diff.Illinois.actual.robust.2 <- diff.in.diff.Illinois.robust.2[length(diff.in.diff.Illinois.robust.2)]

diff.in.diff.Conn.robust.2 <- colMeans(Conn.post.gaps.robust.2) - colMeans(Conn.pre.gaps.robust.2)
diff.in.diff.Conn.placebo.robust.2 <- diff.in.diff.Conn.robust.2[1:(length(diff.in.diff.Conn.robust.2)-1)]
diff.in.diff.Conn.actual.robust.2 <- diff.in.diff.Conn.robust.2[length(diff.in.diff.Conn.robust.2)]

diff.in.diff.NJ.robust.2 <- colMeans(NJ.post.gaps.robust.2) - colMeans(NJ.pre.gaps.robust.2)
diff.in.diff.NJ.placebo.robust.2 <- diff.in.diff.NJ.robust.2[1:(length(diff.in.diff.NJ.robust.2)-1)]
diff.in.diff.NJ.actual.robust.2 <- diff.in.diff.NJ.robust.2[length(diff.in.diff.NJ.robust.2)]

diff.in.diff.Delaware.robust.2 <- colMeans(Delaware.post.gaps.robust.2) - colMeans(Delaware.pre.gaps.robust.2)
diff.in.diff.Delaware.placebo.robust.2 <- diff.in.diff.Delaware.robust.2[1:(length(diff.in.diff.Delaware.robust.2)-1)]
diff.in.diff.Delaware.actual.robust.2 <- diff.in.diff.Delaware.robust.2[length(diff.in.diff.Delaware.robust.2)]

diff.in.diff.Maryland.robust.2 <- colMeans(Maryland.post.gaps.robust.2) - colMeans(Maryland.pre.gaps.robust.2)
diff.in.diff.Maryland.placebo.robust.2 <- diff.in.diff.Maryland.robust.2[1:(length(diff.in.diff.Maryland.robust.2)-1)]
diff.in.diff.Maryland.actual.robust.2 <- diff.in.diff.Maryland.robust.2[length(diff.in.diff.Maryland.robust.2)]

exceeds.ny.robust.2 <- length(diff.in.diff.ny.placebo.robust.2[diff.in.diff.ny.placebo.robust.2>diff.in.diff.ny.actual.robust.2])  
less.than.ny.robust.2 <- length(diff.in.diff.ny.placebo.robust.2)-exceeds.ny.robust.2

exceeds.nm.robust.2 <- length(diff.in.diff.nm.placebo.robust.2[diff.in.diff.nm.placebo.robust.2>diff.in.diff.nm.actual.robust.2])  
less.than.nm.robust.2 <- length(diff.in.diff.nm.placebo.robust.2)-exceeds.nm.robust.2

exceeds.Illinois.robust.2 <- length(diff.in.diff.Illinois.placebo.robust.2[diff.in.diff.Illinois.placebo.robust.2>diff.in.diff.Illinois.actual.robust.2])  
less.than.Illinois.robust.2 <- length(diff.in.diff.Illinois.placebo.robust.2)-exceeds.Illinois.robust.2

exceeds.Conn.robust.2 <- length(diff.in.diff.Conn.placebo.robust.2[diff.in.diff.Conn.placebo.robust.2>diff.in.diff.Conn.actual.robust.2])  
less.than.Conn.robust.2 <- length(diff.in.diff.Conn.placebo.robust.2)-exceeds.Conn.robust.2

exceeds.NJ.robust.2 <- length(diff.in.diff.NJ.placebo.robust.2[diff.in.diff.NJ.placebo.robust.2>diff.in.diff.NJ.actual.robust.2])  
less.than.NJ.robust.2 <- length(diff.in.diff.NJ.placebo.robust.2)-exceeds.NJ.robust.2

exceeds.Delaware.robust.2 <- length(diff.in.diff.Delaware.placebo.robust.2[diff.in.diff.Delaware.placebo.robust.2>diff.in.diff.Delaware.actual.robust.2])  
less.than.Delaware.robust.2 <- length(diff.in.diff.Delaware.placebo.robust.2)-exceeds.Delaware.robust.2

exceeds.Maryland.robust.2 <- length(diff.in.diff.Maryland.placebo.robust.2[diff.in.diff.Maryland.placebo.robust.2>diff.in.diff.Maryland.actual.robust.2])  
less.than.Maryland.robust.2 <- length(diff.in.diff.Maryland.placebo.robust.2)-exceeds.Maryland.robust.2

container.matrix.robust.2 <- matrix(nrow = 7, ncol = 5)
container.matrix.robust.2[1,] <- c("New York", round(diff.in.diff.ny.actual.robust.2, 2), exceeds.ny.robust.2, less.than.ny.robust.2, round((exceeds.ny.robust.2/29), 2))
container.matrix.robust.2[2,] <- c("New Mexico", round(diff.in.diff.nm.actual.robust.2, 2), exceeds.nm.robust.2, less.than.nm.robust.2, round((exceeds.nm.robust.2/29), 2))
container.matrix.robust.2[3,] <- c("Illinois", round(diff.in.diff.Illinois.actual.robust.2, 2), exceeds.Illinois.robust.2, less.than.Illinois.robust.2, round((exceeds.Illinois.robust.2/29), 2))
container.matrix.robust.2[4,] <- c("Connecticut", round(diff.in.diff.Conn.actual.robust.2, 2), exceeds.Conn.robust.2, less.than.Conn.robust.2, round((exceeds.Conn.robust.2/29), 2))
container.matrix.robust.2[5,] <- c("New Jersey", round(diff.in.diff.NJ.actual.robust.2, 2), exceeds.NJ.robust.2, less.than.NJ.robust.2, round((exceeds.NJ.robust.2/29), 2))
container.matrix.robust.2[6,] <- c("Delaware", round(diff.in.diff.Delaware.actual.robust.2, 2), exceeds.Delaware.robust.2, less.than.Delaware.robust.2, round((exceeds.Delaware.robust.2/29), 2))
container.matrix.robust.2[7,] <- c("Maryland", round(diff.in.diff.Maryland.actual.robust.2, 2), exceeds.Maryland.robust.2, less.than.Maryland.robust.2, round((exceeds.Maryland.robust.2/29), 2))

#########################################################
##### Robust 3 (Average Dependent Variable) #########
#########################################################

### New York 

new.york.effect.robust.3 <- dataprep(foo = NY.Set, time.predictors.prior = c(1995:2004), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "ny.lag.whole"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 36, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 

synth.out.robust.3 <- synth(data.prep.obj = new.york.effect.robust.3, method = "All")

path.plot(synth.res = synth.out.robust.3, dataprep.res = new.york.effect.robust.3, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004)

ny.gaps.robust.3 <- new.york.effect.robust.3$Y1plot - (new.york.effect.robust.3$Y0plot %*% synth.out.robust.3$solution.w)


### New Mexico

nm.effect.robust.3 <- dataprep(foo = NM.Set, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nm.lag.whole"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 40, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 

synth.out.2.robust.3 <- synth(data.prep.obj = nm.effect.robust.3, method = "All")

path.plot(synth.res = synth.out.2.robust.3, dataprep.res = nm.effect.robust.3, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009)

nm.gaps.robust.3 <- nm.effect.robust.3$Y1plot - (nm.effect.robust.3$Y0plot %*% synth.out.2.robust.3$solution.w)


### Illinois 

Illinois.effect.robust.3 <- dataprep(foo = Illinois.Set, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "illinois.lag.whole"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 39, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 

synth.out.3.robust.3 <- synth(data.prep.obj = Illinois.effect.robust.3, method = "All")

path.plot(synth.res = synth.out.3.robust.3, dataprep.res = Illinois.effect.robust.3, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011)

Illinois.gaps.robust.3 <- Illinois.effect.robust.3$Y1plot - (Illinois.effect.robust.3$Y0plot %*% synth.out.3.robust.3$solution.w)


### Connecticut

Conn.effect.robust.3 <- dataprep(foo = Conn.Set, time.predictors.prior = c(1995:2012), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "conn.lag.whole"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 41, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 

synth.out.4.robust.3 <- synth(data.prep.obj = Conn.effect.robust.3, method = "All")

path.plot(synth.res = synth.out.4.robust.3, dataprep.res = Conn.effect.robust.3, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012)

Conn.gaps.robust.3 <- Conn.effect.robust.3$Y1plot - (Conn.effect.robust.3$Y0plot %*% synth.out.4.robust.3$solution.w)


### New Jersey

NJ.effect.robust.3 <- dataprep(foo = NJ.Set, time.predictors.prior = c(1995:2007), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nj.lag.whole"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 42, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 

synth.out.5.robust.3 <- synth(data.prep.obj = NJ.effect.robust.3, method = "All")

path.plot(synth.res = synth.out.5.robust.3, dataprep.res = NJ.effect.robust.3, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007)

NJ.gaps.robust.3 <- NJ.effect.robust.3$Y1plot - (NJ.effect.robust.3$Y0plot %*% synth.out.5.robust.3$solution.w)

### Delaware

Delaware.effect.robust.3 <- dataprep(foo = Delaware.Set, time.predictors.prior = c(1995:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "del.lag.whole"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 38, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2016), time.plot = c(1995:2018)) 

synth.out.6.robust.3 <- synth(data.prep.obj = Delaware.effect.robust.3, method = "All")

path.plot(synth.res = synth.out.6.robust.3, dataprep.res = Delaware.effect.robust.3, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016)

Delaware.gaps.robust.3 <- Delaware.effect.robust.3$Y1plot - (Delaware.effect.robust.3$Y0plot %*% synth.out.6.robust.3$solution.w)

### Maryland

Maryland.effect.robust.3 <- dataprep(foo = Maryland.Set, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "maryland.lag.whole"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 37, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 

synth.out.7.robust.3 <- synth(data.prep.obj = Maryland.effect.robust.3, method = "All")

path.plot(synth.res = synth.out.7.robust.3, dataprep.res = Maryland.effect.robust.3, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013)

maryland.tables.robust.3 <- synth.tab(dataprep.res = Maryland.effect.robust.3, synth.res = synth.out.7.robust.3)

maryland.tables.robust.3$tab.pred

Maryland.gaps.robust.3 <- Maryland.effect.robust.3$Y1plot - (Maryland.effect.robust.3$Y0plot %*% synth.out.7.robust.3$solution.w)


########################################
###### Adding to Placebo Gap Analysis ############
########################################

#### NY Placebo Prep
ny.placebos.robust.3 <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.ny.robust.3 <- dataprep(foo = death.set, time.predictors.prior = c(1995:2004), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "ny.lag.whole"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 
  synth.out.9.robust.3 <- synth(data.prep.obj = death.set.effect.ny.robust.3, method = "All")
  death.set.effect.ny.gaps.robust.3 <- death.set.effect.ny.robust.3$Y1plot - (death.set.effect.ny.robust.3$Y0plot %*% synth.out.9.robust.3$solution.w);
  ny.placebos.robust.3[,i] <- death.set.effect.ny.gaps.robust.3
  i <- i + 1
}

final.ny.robust.3 <- cbind(ny.placebos.robust.3, ny.gaps.robust.3)
years <- seq(from=1995, to = 2018, by=1)

#### NM Placebo Prep
NM.placebos.robust.3 <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NM.robust.3 <- dataprep(foo = death.set, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nm.lag.whole"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 
  synth.out.10.robust.3 <- synth(data.prep.obj = death.set.effect.NM.robust.3, method = "All")
  death.set.effect.nm.gaps.robust.3 <- death.set.effect.NM.robust.3$Y1plot - (death.set.effect.NM.robust.3$Y0plot %*% synth.out.10.robust.3$solution.w);
  NM.placebos.robust.3[,i] <- death.set.effect.nm.gaps.robust.3
  i <- i + 1
}

final.NM.robust.3 <- cbind(NM.placebos.robust.3, nm.gaps.robust.3)
years <- seq(from=1995, to = 2018, by=1)


#### Illinois Placebo Prep
Illinois.placebos.robust.3 <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Illinois.robust.3 <- dataprep(foo = death.set, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "illinois.lag.whole"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 
  synth.out.11.robust.3 <- synth(data.prep.obj = death.set.effect.Illinois.robust.3, method = "All")
  death.set.effect.Illinois.gaps.robust.3 <- death.set.effect.Illinois.robust.3$Y1plot - (death.set.effect.Illinois.robust.3$Y0plot %*% synth.out.11.robust.3$solution.w);
  Illinois.placebos.robust.3[,i] <- death.set.effect.Illinois.gaps.robust.3
  i <- i + 1
}

final.Illinois.robust.3 <- cbind(Illinois.placebos.robust.3, Illinois.gaps.robust.3)
years <- seq(from=1995, to = 2018, by=1)


#### Conn Placebo Prep
Conn.placebos.robust.3 <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Conn.robust.3 <- dataprep(foo = death.set, time.predictors.prior = c(1995:2012), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "conn.lag.whole"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 
  synth.out.12.robust.3 <- synth(data.prep.obj = death.set.effect.Conn.robust.3, method = "All")
  death.set.effect.Conn.gaps.robust.3 <- death.set.effect.Conn.robust.3$Y1plot - (death.set.effect.Conn.robust.3$Y0plot %*% synth.out.12.robust.3$solution.w);
  Conn.placebos.robust.3[,i] <- death.set.effect.Conn.gaps.robust.3
  i <- i + 1
}

final.Conn.robust.3 <- cbind(Conn.placebos.robust.3, Conn.gaps.robust.3)
years <- seq(from=1995, to = 2018, by=1)


#### NJ Placebo Prep
NJ.placebos.robust.3 <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NJ.robust.3 <- dataprep(foo = death.set, time.predictors.prior = c(1995:2007), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nj.lag.whole"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 
  synth.out.13.robust.3 <- synth(data.prep.obj = death.set.effect.NJ.robust.3, method = "All")
  death.set.effect.NJ.gaps.robust.3 <- death.set.effect.NJ.robust.3$Y1plot - (death.set.effect.NJ.robust.3$Y0plot %*% synth.out.13.robust.3$solution.w);
  NJ.placebos.robust.3[,i] <- death.set.effect.NJ.gaps.robust.3
  i <- i + 1
}

final.NJ.robust.3 <- cbind(NJ.placebos.robust.3, NJ.gaps.robust.3)
years <- seq(from=1995, to = 2018, by=1)


#### Delaware Placebo Prep
Delaware.placebos.robust.3 <- matrix(nrow = 24, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Delaware.robust.3 <- dataprep(foo = death.set, time.predictors.prior = c(1995:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "del.lag.whole"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2016), time.plot = c(1995:2018)) 
  synth.out.14.robust.3 <- synth(data.prep.obj = death.set.effect.Delaware.robust.3, method = "All")
  death.set.effect.Delaware.gaps.robust.3 <- death.set.effect.Delaware.robust.3$Y1plot - (death.set.effect.Delaware.robust.3$Y0plot %*% synth.out.14.robust.3$solution.w);
  Delaware.placebos.robust.3[,i] <- death.set.effect.Delaware.gaps.robust.3
  i <- i + 1
}

final.Delaware.robust.3 <- cbind(Delaware.placebos.robust.3, Delaware.gaps.robust.3)
years <- seq(from=1995, to = 2018, by=1)

#### Maryland Placebo Prep


maryland.placebos.robust.3 <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.maryland.robust.3 <- dataprep(foo = death.set, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "maryland.lag.whole"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 
  synth.out.8.robust.3 <- synth(data.prep.obj = death.set.effect.maryland.robust.3, method = "All")
  death.set.maryland.gaps.robust.3 <- death.set.effect.maryland.robust.3$Y1plot - (death.set.effect.maryland.robust.3$Y0plot %*% synth.out.8.robust.3$solution.w);
  maryland.placebos.robust.3[,i] <- death.set.maryland.gaps.robust.3
  i <- i + 1
}

maryland.placebos.robust.3
final.maryland.robust.3 <- cbind(maryland.placebos.robust.3, Maryland.gaps.robust.3)
years <- seq(from=1995, to = 2018, by=1)



########################################
########## Permutation Calculations ##########
########################################

ny.pre.gaps.robust.3 <- final.ny.robust.3[1:10,]
ny.post.gaps.robust.3 <- final.ny.robust.3[10:nrow(final.ny.robust.3),]

nm.pre.gaps.robust.3 <- final.NM.robust.3[1:15,]
nm.post.gaps.robust.3 <- final.NM.robust.3[16:nrow(final.NM.robust.3),]

Illinois.pre.gaps.robust.3 <- final.Illinois.robust.3[1:17,]
Illinois.post.gaps.robust.3 <- final.Illinois.robust.3[18:nrow(final.Illinois.robust.3),]

Conn.pre.gaps.robust.3 <- final.Conn.robust.3[1:18,]
Conn.post.gaps.robust.3 <- final.Conn.robust.3[19:nrow(final.Conn.robust.3),]

NJ.pre.gaps.robust.3 <- final.NJ.robust.3[1:13,]
NJ.post.gaps.robust.3 <- final.NJ.robust.3[14:nrow(final.NJ.robust.3),]

Delaware.pre.gaps.robust.3 <- final.Delaware.robust.3[1:22,]
Delaware.post.gaps.robust.3 <- final.Delaware.robust.3[23:nrow(final.Delaware.robust.3),]

Maryland.pre.gaps.robust.3 <- final.maryland.robust.3[1:19,]
Maryland.post.gaps.robust.3 <- final.maryland.robust.3[20:nrow(final.maryland.robust.3),]

diff.in.diff.ny.robust.3 <- colMeans(ny.post.gaps.robust.3) - colMeans(ny.pre.gaps.robust.3)
diff.in.diff.ny.placebo.robust.3 <- diff.in.diff.ny.robust.3[1:(length(diff.in.diff.ny.robust.3)-1)]
diff.in.diff.ny.actual.robust.3 <- diff.in.diff.ny.robust.3[length(diff.in.diff.ny.robust.3)]

diff.in.diff.nm.robust.3 <- colMeans(nm.post.gaps.robust.3) - colMeans(nm.pre.gaps.robust.3)
diff.in.diff.nm.placebo.robust.3 <- diff.in.diff.nm.robust.3[1:(length(diff.in.diff.nm.robust.3)-1)]
diff.in.diff.nm.actual.robust.3 <- diff.in.diff.nm.robust.3[length(diff.in.diff.nm.robust.3)]

diff.in.diff.Illinois.robust.3 <- colMeans(Illinois.post.gaps.robust.3) - colMeans(Illinois.pre.gaps.robust.3)
diff.in.diff.Illinois.placebo.robust.3 <- diff.in.diff.Illinois.robust.3[1:(length(diff.in.diff.Illinois.robust.3)-1)]
diff.in.diff.Illinois.actual.robust.3 <- diff.in.diff.Illinois.robust.3[length(diff.in.diff.Illinois.robust.3)]

diff.in.diff.Conn.robust.3 <- colMeans(Conn.post.gaps.robust.3) - colMeans(Conn.pre.gaps.robust.3)
diff.in.diff.Conn.placebo.robust.3 <- diff.in.diff.Conn.robust.3[1:(length(diff.in.diff.Conn.robust.3)-1)]
diff.in.diff.Conn.actual.robust.3 <- diff.in.diff.Conn.robust.3[length(diff.in.diff.Conn.robust.3)]

diff.in.diff.NJ.robust.3 <- colMeans(NJ.post.gaps.robust.3) - colMeans(NJ.pre.gaps.robust.3)
diff.in.diff.NJ.placebo.robust.3 <- diff.in.diff.NJ.robust.3[1:(length(diff.in.diff.NJ.robust.3)-1)]
diff.in.diff.NJ.actual.robust.3 <- diff.in.diff.NJ.robust.3[length(diff.in.diff.NJ.robust.3)]

diff.in.diff.Delaware.robust.3 <- colMeans(Delaware.post.gaps.robust.3) - colMeans(Delaware.pre.gaps.robust.3)
diff.in.diff.Delaware.placebo.robust.3 <- diff.in.diff.Delaware.robust.3[1:(length(diff.in.diff.Delaware.robust.3)-1)]
diff.in.diff.Delaware.actual.robust.3 <- diff.in.diff.Delaware.robust.3[length(diff.in.diff.Delaware.robust.3)]

diff.in.diff.Maryland.robust.3 <- colMeans(Maryland.post.gaps.robust.3) - colMeans(Maryland.pre.gaps.robust.3)
diff.in.diff.Maryland.placebo.robust.3 <- diff.in.diff.Maryland.robust.3[1:(length(diff.in.diff.Maryland.robust.3)-1)]
diff.in.diff.Maryland.actual.robust.3 <- diff.in.diff.Maryland.robust.3[length(diff.in.diff.Maryland.robust.3)]

exceeds.ny.robust.3 <- length(diff.in.diff.ny.placebo.robust.3[diff.in.diff.ny.placebo.robust.3>diff.in.diff.ny.actual.robust.3])  
less.than.ny.robust.3 <- length(diff.in.diff.ny.placebo.robust.3)-exceeds.ny.robust.3

exceeds.nm.robust.3 <- length(diff.in.diff.nm.placebo.robust.3[diff.in.diff.nm.placebo.robust.3>diff.in.diff.nm.actual.robust.3])  
less.than.nm.robust.3 <- length(diff.in.diff.nm.placebo.robust.3)-exceeds.nm.robust.3

exceeds.Illinois.robust.3 <- length(diff.in.diff.Illinois.placebo.robust.3[diff.in.diff.Illinois.placebo.robust.3>diff.in.diff.Illinois.actual.robust.3])  
less.than.Illinois.robust.3 <- length(diff.in.diff.Illinois.placebo.robust.3)-exceeds.Illinois.robust.3

exceeds.Conn.robust.3 <- length(diff.in.diff.Conn.placebo.robust.3[diff.in.diff.Conn.placebo.robust.3>diff.in.diff.Conn.actual.robust.3])  
less.than.Conn.robust.3 <- length(diff.in.diff.Conn.placebo.robust.3)-exceeds.Conn.robust.3

exceeds.NJ.robust.3 <- length(diff.in.diff.NJ.placebo.robust.3[diff.in.diff.NJ.placebo.robust.3>diff.in.diff.NJ.actual.robust.3])  
less.than.NJ.robust.3 <- length(diff.in.diff.NJ.placebo.robust.3)-exceeds.NJ.robust.3

exceeds.Delaware.robust.3 <- length(diff.in.diff.Delaware.placebo.robust.3[diff.in.diff.Delaware.placebo.robust.3>diff.in.diff.Delaware.actual.robust.3])  
less.than.Delaware.robust.3 <- length(diff.in.diff.Delaware.placebo.robust.3)-exceeds.Delaware.robust.3

exceeds.Maryland.robust.3 <- length(diff.in.diff.Maryland.placebo.robust.3[diff.in.diff.Maryland.placebo.robust.3>diff.in.diff.Maryland.actual.robust.3])  
less.than.Maryland.robust.3 <- length(diff.in.diff.Maryland.placebo.robust.3)-exceeds.Maryland.robust.3

container.matrix.robust.3 <- matrix(nrow = 7, ncol = 5)
container.matrix.robust.3[1,] <- c("New York", round(diff.in.diff.ny.actual.robust.3, 2), exceeds.ny.robust.3, less.than.ny.robust.3, round((exceeds.ny.robust.3/29), 2))
container.matrix.robust.3[2,] <- c("New Mexico", round(diff.in.diff.nm.actual.robust.3, 2), exceeds.nm.robust.3, less.than.nm.robust.3, round((exceeds.nm.robust.3/29), 2))
container.matrix.robust.3[3,] <- c("Illinois", round(diff.in.diff.Illinois.actual.robust.3, 2), exceeds.Illinois.robust.3, less.than.Illinois.robust.3, round((exceeds.Illinois.robust.3/29), 2))
container.matrix.robust.3[4,] <- c("Connecticut", round(diff.in.diff.Conn.actual.robust.3, 2), exceeds.Conn.robust.3, less.than.Conn.robust.3, round((exceeds.Conn.robust.3/29), 2))
container.matrix.robust.3[5,] <- c("New Jersey", round(diff.in.diff.NJ.actual.robust.3, 2), exceeds.NJ.robust.3, less.than.NJ.robust.3, round((exceeds.NJ.robust.3/29), 2))
container.matrix.robust.3[6,] <- c("Delaware", round(diff.in.diff.Delaware.actual.robust.3, 2), exceeds.Delaware.robust.3, less.than.Delaware.robust.3, round((exceeds.Delaware.robust.3/29), 2))
container.matrix.robust.3[7,] <- c("Maryland", round(diff.in.diff.Maryland.actual.robust.3, 2), exceeds.Maryland.robust.3, less.than.Maryland.robust.3, round((exceeds.Maryland.robust.3/29), 2))

########################################
##### Robust 4 (One Year Lag) #########
########################################

### New York 

new.york.effect.robust.4 <- dataprep(foo = NY.Set, time.predictors.prior = c(1995:2004), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "ny.lag.1"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 36, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 

synth.out.robust.4 <- synth(data.prep.obj = new.york.effect.robust.4, method = "All")

path.plot(synth.res = synth.out.robust.4, dataprep.res = new.york.effect.robust.4, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004)

ny.gaps.robust.4 <- new.york.effect.robust.4$Y1plot - (new.york.effect.robust.4$Y0plot %*% synth.out.robust.4$solution.w)


### New Mexico

nm.effect.robust.4 <- dataprep(foo = NM.Set, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nm.lag.1"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 40, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 

synth.out.2.robust.4 <- synth(data.prep.obj = nm.effect.robust.4, method = "All")

path.plot(synth.res = synth.out.2.robust.4, dataprep.res = nm.effect.robust.4, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009)

nm.gaps.robust.4 <- nm.effect.robust.4$Y1plot - (nm.effect.robust.4$Y0plot %*% synth.out.2.robust.4$solution.w)


### Illinois 

Illinois.effect.robust.4 <- dataprep(foo = Illinois.Set, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "illinois.lag.1"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 39, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 

synth.out.3.robust.4 <- synth(data.prep.obj = Illinois.effect.robust.4, method = "All")

path.plot(synth.res = synth.out.3.robust.4, dataprep.res = Illinois.effect.robust.4, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011)

Illinois.gaps.robust.4 <- Illinois.effect.robust.4$Y1plot - (Illinois.effect.robust.4$Y0plot %*% synth.out.3.robust.4$solution.w)


### Connecticut

Conn.effect.robust.4 <- dataprep(foo = Conn.Set, time.predictors.prior = c(1995:2012), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "conn.lag.1"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 41, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 

synth.out.4.robust.4 <- synth(data.prep.obj = Conn.effect.robust.4, method = "All")

path.plot(synth.res = synth.out.4.robust.4, dataprep.res = Conn.effect.robust.4, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012)

Conn.gaps.robust.4 <- Conn.effect.robust.4$Y1plot - (Conn.effect.robust.4$Y0plot %*% synth.out.4.robust.4$solution.w)


### New Jersey

NJ.effect.robust.4 <- dataprep(foo = NJ.Set, time.predictors.prior = c(1995:2007), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nj.lag.1"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 42, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 

synth.out.5.robust.4 <- synth(data.prep.obj = NJ.effect.robust.4, method = "All")

path.plot(synth.res = synth.out.5.robust.4, dataprep.res = NJ.effect.robust.4, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007)

NJ.gaps.robust.4 <- NJ.effect.robust.4$Y1plot - (NJ.effect.robust.4$Y0plot %*% synth.out.5.robust.4$solution.w)

### Delaware

Delaware.effect.robust.4 <- dataprep(foo = Delaware.Set, time.predictors.prior = c(1995:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "del.lag.1"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 38, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2016), time.plot = c(1995:2018)) 

synth.out.6.robust.4 <- synth(data.prep.obj = Delaware.effect.robust.4, method = "All")

path.plot(synth.res = synth.out.6.robust.4, dataprep.res = Delaware.effect.robust.4, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016)

Delaware.gaps.robust.4 <- Delaware.effect.robust.4$Y1plot - (Delaware.effect.robust.4$Y0plot %*% synth.out.6.robust.4$solution.w)

### Maryland

Maryland.effect.robust.4 <- dataprep(foo = Maryland.Set, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "maryland.lag.1"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 37, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 

synth.out.7.robust.4 <- synth(data.prep.obj = Maryland.effect.robust.4, method = "All")

path.plot(synth.res = synth.out.7.robust.4, dataprep.res = Maryland.effect.robust.4, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013)

maryland.tables.robust.4 <- synth.tab(dataprep.res = Maryland.effect.robust.4, synth.res = synth.out.7.robust.4)

maryland.tables.robust.4$tab.pred

Maryland.gaps.robust.4 <- Maryland.effect.robust.4$Y1plot - (Maryland.effect.robust.4$Y0plot %*% synth.out.7.robust.4$solution.w)




########################################
###### Adding to Placebo Gap Analysis ############
########################################

#### NY Placebo Prep
ny.placebos.robust.4 <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.ny.robust.4 <- dataprep(foo = death.set, time.predictors.prior = c(1995:2004), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "ny.lag.1"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 
  synth.out.9.robust.4 <- synth(data.prep.obj = death.set.effect.ny.robust.4, method = "All")
  death.set.effect.ny.gaps.robust.4 <- death.set.effect.ny.robust.4$Y1plot - (death.set.effect.ny.robust.4$Y0plot %*% synth.out.9.robust.4$solution.w);
  ny.placebos.robust.4[,i] <- death.set.effect.ny.gaps.robust.4
  i <- i + 1
}

final.ny.robust.4 <- cbind(ny.placebos.robust.4, ny.gaps.robust.4)
years <- seq(from=1995, to = 2018, by=1)

#### NM Placebo Prep
NM.placebos.robust.4 <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NM.robust.4 <- dataprep(foo = death.set, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nm.lag.1"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 
  synth.out.10.robust.4 <- synth(data.prep.obj = death.set.effect.NM.robust.4, method = "All")
  death.set.effect.nm.gaps.robust.4 <- death.set.effect.NM.robust.4$Y1plot - (death.set.effect.NM.robust.4$Y0plot %*% synth.out.10.robust.4$solution.w);
  NM.placebos.robust.4[,i] <- death.set.effect.nm.gaps.robust.4
  i <- i + 1
}

final.NM.robust.4 <- cbind(NM.placebos.robust.4, nm.gaps.robust.4)
years <- seq(from=1995, to = 2018, by=1)


#### Illinois Placebo Prep
Illinois.placebos.robust.4 <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Illinois.robust.4 <- dataprep(foo = death.set, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "illinois.lag.1"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 
  synth.out.11.robust.4 <- synth(data.prep.obj = death.set.effect.Illinois.robust.4, method = "All")
  death.set.effect.Illinois.gaps.robust.4 <- death.set.effect.Illinois.robust.4$Y1plot - (death.set.effect.Illinois.robust.4$Y0plot %*% synth.out.11.robust.4$solution.w);
  Illinois.placebos.robust.4[,i] <- death.set.effect.Illinois.gaps.robust.4
  i <- i + 1
}

final.Illinois.robust.4 <- cbind(Illinois.placebos.robust.4, Illinois.gaps.robust.4)
years <- seq(from=1995, to = 2018, by=1)


#### Conn Placebo Prep
Conn.placebos.robust.4 <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Conn.robust.4 <- dataprep(foo = death.set, time.predictors.prior = c(1995:2012), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "conn.lag.1"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 
  synth.out.12.robust.4 <- synth(data.prep.obj = death.set.effect.Conn.robust.4, method = "All")
  death.set.effect.Conn.gaps.robust.4 <- death.set.effect.Conn.robust.4$Y1plot - (death.set.effect.Conn.robust.4$Y0plot %*% synth.out.12.robust.4$solution.w);
  Conn.placebos.robust.4[,i] <- death.set.effect.Conn.gaps.robust.4
  i <- i + 1
}

final.Conn.robust.4 <- cbind(Conn.placebos.robust.4, Conn.gaps.robust.4)
years <- seq(from=1995, to = 2018, by=1)


#### NJ Placebo Prep
NJ.placebos.robust.4 <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NJ.robust.4 <- dataprep(foo = death.set, time.predictors.prior = c(1995:2007), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nj.lag.1"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 
  synth.out.13.robust.4 <- synth(data.prep.obj = death.set.effect.NJ.robust.4, method = "All")
  death.set.effect.NJ.gaps.robust.4 <- death.set.effect.NJ.robust.4$Y1plot - (death.set.effect.NJ.robust.4$Y0plot %*% synth.out.13.robust.4$solution.w);
  NJ.placebos.robust.4[,i] <- death.set.effect.NJ.gaps.robust.4
  i <- i + 1
}

final.NJ.robust.4 <- cbind(NJ.placebos.robust.4, NJ.gaps.robust.4)
years <- seq(from=1995, to = 2018, by=1)


#### Delaware Placebo Prep
Delaware.placebos.robust.4 <- matrix(nrow = 24, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Delaware.robust.4 <- dataprep(foo = death.set, time.predictors.prior = c(1995:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "del.lag.1"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2016), time.plot = c(1995:2018)) 
  synth.out.14.robust.4 <- synth(data.prep.obj = death.set.effect.Delaware.robust.4, method = "All")
  death.set.effect.Delaware.gaps.robust.4 <- death.set.effect.Delaware.robust.4$Y1plot - (death.set.effect.Delaware.robust.4$Y0plot %*% synth.out.14.robust.4$solution.w);
  Delaware.placebos.robust.4[,i] <- death.set.effect.Delaware.gaps.robust.4
  i <- i + 1
}

final.Delaware.robust.4 <- cbind(Delaware.placebos.robust.4, Delaware.gaps.robust.4)
years <- seq(from=1995, to = 2018, by=1)

#### Maryland Placebo Prep


maryland.placebos.robust.4 <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.maryland.robust.4 <- dataprep(foo = death.set, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "maryland.lag.1"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 
  synth.out.8.robust.4 <- synth(data.prep.obj = death.set.effect.maryland.robust.4, method = "All")
  death.set.maryland.gaps.robust.4 <- death.set.effect.maryland.robust.4$Y1plot - (death.set.effect.maryland.robust.4$Y0plot %*% synth.out.8.robust.4$solution.w);
  maryland.placebos.robust.4[,i] <- death.set.maryland.gaps.robust.4
  i <- i + 1
}

maryland.placebos.robust.4
final.maryland.robust.4 <- cbind(maryland.placebos.robust.4, Maryland.gaps.robust.4)
years <- seq(from=1995, to = 2018, by=1)



########################################
########## Permutation Calculations ##########
########################################

ny.pre.gaps.robust.4 <- final.ny.robust.4[1:10,]
ny.post.gaps.robust.4 <- final.ny.robust.4[10:nrow(final.ny.robust.4),]

nm.pre.gaps.robust.4 <- final.NM.robust.4[1:15,]
nm.post.gaps.robust.4 <- final.NM.robust.4[16:nrow(final.NM.robust.4),]

Illinois.pre.gaps.robust.4 <- final.Illinois.robust.4[1:17,]
Illinois.post.gaps.robust.4 <- final.Illinois.robust.4[18:nrow(final.Illinois.robust.4),]

Conn.pre.gaps.robust.4 <- final.Conn.robust.4[1:18,]
Conn.post.gaps.robust.4 <- final.Conn.robust.4[19:nrow(final.Conn.robust.4),]

NJ.pre.gaps.robust.4 <- final.NJ.robust.4[1:13,]
NJ.post.gaps.robust.4 <- final.NJ.robust.4[14:nrow(final.NJ.robust.4),]

Delaware.pre.gaps.robust.4 <- final.Delaware.robust.4[1:22,]
Delaware.post.gaps.robust.4 <- final.Delaware.robust.4[23:nrow(final.Delaware.robust.4),]

Maryland.pre.gaps.robust.4 <- final.maryland.robust.4[1:19,]
Maryland.post.gaps.robust.4 <- final.maryland.robust.4[20:nrow(final.maryland.robust.4),]

diff.in.diff.ny.robust.4 <- colMeans(ny.post.gaps.robust.4) - colMeans(ny.pre.gaps.robust.4)
diff.in.diff.ny.placebo.robust.4 <- diff.in.diff.ny.robust.4[1:(length(diff.in.diff.ny.robust.4)-1)]
diff.in.diff.ny.actual.robust.4 <- diff.in.diff.ny.robust.4[length(diff.in.diff.ny.robust.4)]

diff.in.diff.nm.robust.4 <- colMeans(nm.post.gaps.robust.4) - colMeans(nm.pre.gaps.robust.4)
diff.in.diff.nm.placebo.robust.4 <- diff.in.diff.nm.robust.4[1:(length(diff.in.diff.nm.robust.4)-1)]
diff.in.diff.nm.actual.robust.4 <- diff.in.diff.nm.robust.4[length(diff.in.diff.nm.robust.4)]

diff.in.diff.Illinois.robust.4 <- colMeans(Illinois.post.gaps.robust.4) - colMeans(Illinois.pre.gaps.robust.4)
diff.in.diff.Illinois.placebo.robust.4 <- diff.in.diff.Illinois.robust.4[1:(length(diff.in.diff.Illinois.robust.4)-1)]
diff.in.diff.Illinois.actual.robust.4 <- diff.in.diff.Illinois.robust.4[length(diff.in.diff.Illinois.robust.4)]

diff.in.diff.Conn.robust.4 <- colMeans(Conn.post.gaps.robust.4) - colMeans(Conn.pre.gaps.robust.4)
diff.in.diff.Conn.placebo.robust.4 <- diff.in.diff.Conn.robust.4[1:(length(diff.in.diff.Conn.robust.4)-1)]
diff.in.diff.Conn.actual.robust.4 <- diff.in.diff.Conn.robust.4[length(diff.in.diff.Conn.robust.4)]

diff.in.diff.NJ.robust.4 <- colMeans(NJ.post.gaps.robust.4) - colMeans(NJ.pre.gaps.robust.4)
diff.in.diff.NJ.placebo.robust.4 <- diff.in.diff.NJ.robust.4[1:(length(diff.in.diff.NJ.robust.4)-1)]
diff.in.diff.NJ.actual.robust.4 <- diff.in.diff.NJ.robust.4[length(diff.in.diff.NJ.robust.4)]

diff.in.diff.Delaware.robust.4 <- colMeans(Delaware.post.gaps.robust.4) - colMeans(Delaware.pre.gaps.robust.4)
diff.in.diff.Delaware.placebo.robust.4 <- diff.in.diff.Delaware.robust.4[1:(length(diff.in.diff.Delaware.robust.4)-1)]
diff.in.diff.Delaware.actual.robust.4 <- diff.in.diff.Delaware.robust.4[length(diff.in.diff.Delaware.robust.4)]

diff.in.diff.Maryland.robust.4 <- colMeans(Maryland.post.gaps.robust.4) - colMeans(Maryland.pre.gaps.robust.4)
diff.in.diff.Maryland.placebo.robust.4 <- diff.in.diff.Maryland.robust.4[1:(length(diff.in.diff.Maryland.robust.4)-1)]
diff.in.diff.Maryland.actual.robust.4 <- diff.in.diff.Maryland.robust.4[length(diff.in.diff.Maryland.robust.4)]

exceeds.ny.robust.4 <- length(diff.in.diff.ny.placebo.robust.4[diff.in.diff.ny.placebo.robust.4>diff.in.diff.ny.actual.robust.4])  
less.than.ny.robust.4 <- length(diff.in.diff.ny.placebo.robust.4)-exceeds.ny.robust.4

exceeds.nm.robust.4 <- length(diff.in.diff.nm.placebo.robust.4[diff.in.diff.nm.placebo.robust.4>diff.in.diff.nm.actual.robust.4])  
less.than.nm.robust.4 <- length(diff.in.diff.nm.placebo.robust.4)-exceeds.nm.robust.4

exceeds.Illinois.robust.4 <- length(diff.in.diff.Illinois.placebo.robust.4[diff.in.diff.Illinois.placebo.robust.4>diff.in.diff.Illinois.actual.robust.4])  
less.than.Illinois.robust.4 <- length(diff.in.diff.Illinois.placebo.robust.4)-exceeds.Illinois.robust.4

exceeds.Conn.robust.4 <- length(diff.in.diff.Conn.placebo.robust.4[diff.in.diff.Conn.placebo.robust.4>diff.in.diff.Conn.actual.robust.4])  
less.than.Conn.robust.4 <- length(diff.in.diff.Conn.placebo.robust.4)-exceeds.Conn.robust.4

exceeds.NJ.robust.4 <- length(diff.in.diff.NJ.placebo.robust.4[diff.in.diff.NJ.placebo.robust.4>diff.in.diff.NJ.actual.robust.4])  
less.than.NJ.robust.4 <- length(diff.in.diff.NJ.placebo.robust.4)-exceeds.NJ.robust.4

exceeds.Delaware.robust.4 <- length(diff.in.diff.Delaware.placebo.robust.4[diff.in.diff.Delaware.placebo.robust.4>diff.in.diff.Delaware.actual.robust.4])  
less.than.Delaware.robust.4 <- length(diff.in.diff.Delaware.placebo.robust.4)-exceeds.Delaware.robust.4

exceeds.Maryland.robust.4 <- length(diff.in.diff.Maryland.placebo.robust.4[diff.in.diff.Maryland.placebo.robust.4>diff.in.diff.Maryland.actual.robust.4])  
less.than.Maryland.robust.4 <- length(diff.in.diff.Maryland.placebo.robust.4)-exceeds.Maryland.robust.4

container.matrix.robust.4 <- matrix(nrow = 7, ncol = 5)
container.matrix.robust.4[1,] <- c("New York", round(diff.in.diff.ny.actual.robust.4, 2), exceeds.ny.robust.4, less.than.ny.robust.4, round((exceeds.ny.robust.4/29), 2))
container.matrix.robust.4[2,] <- c("New Mexico", round(diff.in.diff.nm.actual.robust.4, 2), exceeds.nm.robust.4, less.than.nm.robust.4, round((exceeds.nm.robust.4/29), 2))
container.matrix.robust.4[3,] <- c("Illinois", round(diff.in.diff.Illinois.actual.robust.4, 2), exceeds.Illinois.robust.4, less.than.Illinois.robust.4, round((exceeds.Illinois.robust.4/29), 2))
container.matrix.robust.4[4,] <- c("Connecticut", round(diff.in.diff.Conn.actual.robust.4, 2), exceeds.Conn.robust.4, less.than.Conn.robust.4, round((exceeds.Conn.robust.4/29), 2))
container.matrix.robust.4[5,] <- c("New Jersey", round(diff.in.diff.NJ.actual.robust.4, 2), exceeds.NJ.robust.4, less.than.NJ.robust.4, round((exceeds.NJ.robust.4/29), 2))
container.matrix.robust.4[6,] <- c("Delaware", round(diff.in.diff.Delaware.actual.robust.4, 2), exceeds.Delaware.robust.4, less.than.Delaware.robust.4, round((exceeds.Delaware.robust.4/29), 2))
container.matrix.robust.4[7,] <- c("Maryland", round(diff.in.diff.Maryland.actual.robust.4, 2), exceeds.Maryland.robust.4, less.than.Maryland.robust.4, round((exceeds.Maryland.robust.4/29), 2))



huge.table <- rbind(container.matrix.robust.2, container.matrix.robust.3, container.matrix.robust.4)

huge.table <- as.data.frame(huge.table)



##################### Testing Illinois Moratorium #############################

Illinois.effect.1999 <- dataprep(foo = Illinois.Set, time.predictors.prior = c(1995:2000), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "illinois.lag.16"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 39, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2000), time.plot = c(1995:2017)) 


synth.out.3.1999 <- synth(data.prep.obj = Illinois.effect.1999, method = "All")

Illinois.tables.1999 <- synth.tab(dataprep.res = Illinois.effect.1999, synth.res = synth.out.3.1999)

Illinois.gaps.defacto <- Illinois.effect.1999$Y1plot - (Illinois.effect.1999$Y0plot %*% synth.out.3.1999$solution.w)


par(oma = c(6,4,4,4), mar = c(4, 4, 4, 4), pch=20)
path.plot(synth.res = synth.out.3.1999, dataprep.res = Illinois.effect.1999, Ylab = "Log Murder Rate", Xlab = "Year", Legend = NA, Main = "Figure 6: Assessing the Impact of the 2000 Moratorium in Illinois", Ylim = c(0,5))
abline(v=2000, col = "red")
legend.cols <- c("black", "black", "red")
names(legend.cols) <- c("Treated", "Synthetic Control", "Year Moratorium Imposed")
par(fig= c(0, 1, 0, 1), oma = c(0,0,0,0), mar = c(.5, .5, .5, .5), new=TRUE)
plot(0,0, type = "n", bty="n", xaxt ="n", yaxt="n")
legend("bottomleft", text.width=c(0.3,0.3,0.3), legend=names(legend.cols), col = legend.cols, lty = c(1,2,1), lwd = c(2.5, 2.5, 2.5), cex = .75, xpd = TRUE, horiz = F, inset = c(0,0,0), bty = "y", text.font = 2)

########################################
##### Stranger Homicide Rates #########
########################################


### New York 

new.york.effect.stranger <- dataprep(foo = NY.Set, time.predictors.prior = c(1995:2004), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "ny.lag.1.stranger", "ny.lag.5.stranger", "ny.lag.9.stranger"), dependent = "stranger.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 36, controls.identifier = c(2,3,4,5,7,9,11,12,13,14,16,18,19,20,21,22,23,25,26,27,28), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 

synth.out.stranger <- synth(data.prep.obj = new.york.effect.stranger, method = "All")

ny.tables.stranger <- synth.tab(dataprep.res = new.york.effect.stranger, synth.res = synth.out.stranger)

path.plot(synth.res = synth.out.stranger, dataprep.res = new.york.effect.stranger, Ylab = "Stranger Homicide Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004)

ny.gaps.stranger <- new.york.effect.stranger$Y1plot - (new.york.effect.stranger$Y0plot %*% synth.out.stranger$solution.w)


### New Mexico

nm.effect.stranger <- dataprep(foo = NM.Set, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nm.lag.1.stranger", "nm.lag.7.stranger", "nm.lag.14.stranger"), dependent = "stranger.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 40, controls.identifier = c(2,3,4,5,7,9,11,12,13,14,16,18,19,20,21,22,23,25,26,27,28), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 

synth.out.2.stranger <- synth(data.prep.obj = nm.effect.stranger, method = "All")

nm.tables.stranger <- synth.tab(dataprep.res = nm.effect.stranger, synth.res = synth.out.2.stranger)


path.plot(synth.res = synth.out.2.stranger, dataprep.res = nm.effect.stranger, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009)

nm.gaps.stranger <- nm.effect.stranger$Y1plot - (nm.effect.stranger$Y0plot %*% synth.out.2.stranger$solution.w)


### Illinois 

Illinois.effect.stranger <- dataprep(foo = Illinois.Set, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "illinois.lag.1.stranger", "illinois.lag.8.stranger", "illinois.lag.16.stranger"), dependent = "stranger.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 39, controls.identifier = c(2,3,4,5,7,9,11,12,13,14,16,18,19,20,21,22,23,25,26,27,28), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 

synth.out.3.stranger <- synth(data.prep.obj = Illinois.effect.stranger, method = "All")

Illinois.tables.stranger <- synth.tab(dataprep.res = Illinois.effect.stranger, synth.res = synth.out.3.stranger)

path.plot(synth.res = synth.out.3.stranger, dataprep.res = Illinois.effect.stranger, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011)

Illinois.gaps.stranger <- Illinois.effect.stranger$Y1plot - (Illinois.effect.stranger$Y0plot %*% synth.out.3.stranger$solution.w)


### Connecticut

Conn.effect.stranger <- dataprep(foo = Conn.Set, time.predictors.prior = c(1995:2012), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "conn.lag.1.stranger", "conn.lag.9.stranger", "conn.lag.17.stranger"), dependent = "stranger.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 41, controls.identifier = c(2,3,4,5,7,9,11,12,13,14,16,18,19,20,21,22,23,25,26,27,28), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 

synth.out.4.stranger <- synth(data.prep.obj = Conn.effect.stranger, method = "All")

Conn.tables.stranger <- synth.tab(dataprep.res = Conn.effect.stranger, synth.res = synth.out.4.stranger)

path.plot(synth.res = synth.out.4.stranger, dataprep.res = Conn.effect.stranger, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012)

Conn.gaps.stranger <- Conn.effect.stranger$Y1plot - (Conn.effect.stranger$Y0plot %*% synth.out.4.stranger$solution.w)


### New Jersey

NJ.effect.stranger <- dataprep(foo = NJ.Set, time.predictors.prior = c(1995:2007), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nj.lag.1.stranger", "nj.lag.6.stranger", "nj.lag.12.stranger"), dependent = "stranger.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 42, controls.identifier = c(2,3,4,5,7,9,11,12,13,14,16,18,19,20,21,22,23,25,26,27,28), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 

synth.out.5.stranger  <- synth(data.prep.obj = NJ.effect.stranger, method = "All")

NJ.tables.stranger <- synth.tab(dataprep.res = NJ.effect.stranger, synth.res = synth.out.5.stranger)

path.plot(synth.res = synth.out.5.stranger, dataprep.res = NJ.effect.stranger, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007)

NJ.gaps.stranger <- NJ.effect.stranger$Y1plot - (NJ.effect.stranger$Y0plot %*% synth.out.5.stranger$solution.w)

### Delaware

Delaware.effect.stranger <- dataprep(foo = Delaware.Set, time.predictors.prior = c(1996:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "del.lag.1.stranger", "del.lag.11.stranger", "del.lag.21.stranger"), dependent = "stranger.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 38, controls.identifier = c(2,3,4,5,7,9,11,12,13,14,16,18,19,20,21,22,23,25,26,27,28), time.optimize.ssr = c(1996:2016), time.plot = c(1996:2018)) 

synth.out.6.stranger <- synth(data.prep.obj = Delaware.effect.stranger, method = "All")

path.plot(synth.res = synth.out.6.stranger, dataprep.res = Delaware.effect.stranger, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016)

Delaware.gaps.stranger <- Delaware.effect.stranger$Y1plot - (Delaware.effect.stranger$Y0plot %*% synth.out.6.stranger$solution.w)

### Maryland

Maryland.effect.stranger <- dataprep(foo = Maryland.Set, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "maryland.lag.1.stranger", "maryland.lag.9.stranger", "maryland.lag.18.stranger"), dependent = "stranger.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 37, controls.identifier = c(2,3,4,5,7,9,11,12,13,14,16,18,19,20,21,22,23,25,26,27,28), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 

synth.out.7.stranger <- synth(data.prep.obj = Maryland.effect.stranger, method = "All")

path.plot(synth.res = synth.out.7.stranger, dataprep.res = Maryland.effect.stranger, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013)

Maryland.tables.stranger <- synth.tab(dataprep.res = Maryland.effect.stranger, synth.res = synth.out.7.stranger)

Maryland.gaps.stranger <- Maryland.effect.stranger$Y1plot - (Maryland.effect.stranger$Y0plot %*% synth.out.7.stranger$solution.w)



############### ############### ############### 
############### Single Plot ###############
############### ############### ############### 



### New York 

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))
path.plot(synth.res = synth.out.stranger, dataprep.res = new.york.effect.stranger, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004, col = "red")

### New Mexico


path.plot(synth.res = synth.out.2.stranger, dataprep.res = nm.effect.stranger, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009, col = "red")
mtext("Figure 5: Synthetic Control Plots for States That Eliminated Capital Punishment (y = Stranger Murders Per 100,000 Residents)", side = 3, line = 4, font = 2)

### Illinois 


path.plot(synth.res = synth.out.3.stranger, dataprep.res = Illinois.effect.stranger, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011, col = "red")



### Connecticut


path.plot(synth.res = synth.out.4.stranger, dataprep.res = Conn.effect.stranger, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012, col = "red")


### New Jersey


path.plot(synth.res = synth.out.5.stranger, dataprep.res = NJ.effect.stranger, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007, col = "red")

### Delaware

path.plot(synth.res = synth.out.6.stranger, dataprep.res = Delaware.effect.stranger, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016, col = "red")


### Maryland

path.plot(synth.res = synth.out.7.stranger, dataprep.res = Maryland.effect.stranger, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013, col = "red")

legend.cols <- c("black", "black", "red")
names(legend.cols) <- c("Treated", "Synthetic Control", "Year Eliminated DP")
par(fig= c(0, 1, 0, 1), oma = c(0,0,0,0), mar = c(.5, .5, .5, .5), new=TRUE)
plot(0,0, type = "n", bty="n", xaxt ="n", yaxt="n")
legend("bottom", text.width=c(0.3,0.3,0.3), legend=names(legend.cols), col = legend.cols, lty = c(1,2,1), lwd = c(2.5, 2.5, 2.5), cex = .75, xpd = TRUE, horiz = F, inset = c(0,0,0), bty = "y", text.font = 2)


########################################
###### Adding to Placebo Gap Analysis ############
########################################

#### NY Placebo Prep
ny.placebos.stranger <- matrix(nrow = 21, ncol = 21)
i <- 1
for (s in c(2,3,4,5,7,9,11,12,13,14,16,18,19,20,21,22,23,25,26,27,28)) {
  controls <- c(2,3,4,5,7,9,11,12,13,14,16,18,19,20,21,22,23,25,26,27,28)
  controls.complete <- controls[controls!=s]
  death.set.effect.ny <- dataprep(foo = death.set, time.predictors.prior = c(1995:2004), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "ny.lag.1.stranger", "ny.lag.5.stranger", "ny.lag.9.stranger"), dependent = "stranger.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 
  synth.out.9 <- synth(data.prep.obj = death.set.effect.ny, method = "All")
  death.set.effect.ny.gaps <- death.set.effect.ny$Y1plot - (death.set.effect.ny$Y0plot %*% synth.out.9$solution.w);
  ny.placebos.stranger[,i] <- death.set.effect.ny.gaps
  i <- i + 1
}

final.ny.stranger <- cbind(ny.placebos.stranger, ny.gaps.stranger)
years <- seq(from=1995, to = 2018, by=1)

#### NM Placebo Prep
NM.placebos.stranger <- matrix(nrow = 21, ncol = 21)
i <- 1
for (s in c(2,3,4,5,7,9,11,12,13,14,16,18,19,20,21,22,23,25,26,27,28)) {
  controls <- c(2,3,4,5,7,9,11,12,13,14,16,18,19,20,21,22,23,25,26,27,28)
  controls.complete <- controls[controls!=s]
  death.set.effect.NM <- dataprep(foo = death.set, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nm.lag.1.stranger", "nm.lag.7.stranger", "nm.lag.14.stranger"), dependent = "stranger.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 
  synth.out.10 <- synth(data.prep.obj = death.set.effect.NM, method = "All")
  death.set.effect.nm.gaps <- death.set.effect.NM$Y1plot - (death.set.effect.NM$Y0plot %*% synth.out.10$solution.w);
  NM.placebos.stranger[,i] <- death.set.effect.nm.gaps
  i <- i + 1
}

final.NM.stranger <- cbind(NM.placebos.stranger, nm.gaps.stranger)
years <- seq(from=1995, to = 2018, by=1)


#### Illinois Placebo Prep
Illinois.placebos.stranger <- matrix(nrow = 23, ncol = 21)
i <- 1
for (s in c(2,3,4,5,7,9,11,12,13,14,16,18,19,20,21,22,23,25,26,27,28)) {
  controls <- c(2,3,4,5,7,9,11,12,13,14,16,18,19,20,21,22,23,25,26,27,28)
  controls.complete <- controls[controls!=s]
  death.set.effect.Illinois <- dataprep(foo = death.set, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "illinois.lag.1.stranger", "illinois.lag.8.stranger", "illinois.lag.16.stranger"), dependent = "stranger.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 
  synth.out.11 <- synth(data.prep.obj = death.set.effect.Illinois, method = "All")
  death.set.effect.Illinois.gaps <- death.set.effect.Illinois$Y1plot - (death.set.effect.Illinois$Y0plot %*% synth.out.11$solution.w);
  Illinois.placebos.stranger[,i] <- death.set.effect.Illinois.gaps
  i <- i + 1
}

final.Illinois.stranger <- cbind(Illinois.placebos.stranger, Illinois.gaps.stranger)
years <- seq(from=1995, to = 2018, by=1)


#### Conn Placebo Prep
Conn.placebos.stranger <- matrix(nrow = 23, ncol = 21)
i <- 1
for (s in c(2,3,4,5,7,9,11,12,13,14,16,18,19,20,21,22,23,25,26,27,28)) {
  controls <- c(2,3,4,5,7,9,11,12,13,14,16,18,19,20,21,22,23,25,26,27,28)
  controls.complete <- controls[controls!=s]
  death.set.effect.Conn <- dataprep(foo = death.set, time.predictors.prior = c(1995:2012), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "conn.lag.1.stranger", "conn.lag.9.stranger", "conn.lag.17.stranger"), dependent = "stranger.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 
  synth.out.12 <- synth(data.prep.obj = death.set.effect.Conn, method = "All")
  death.set.effect.Conn.gaps <- death.set.effect.Conn$Y1plot - (death.set.effect.Conn$Y0plot %*% synth.out.12$solution.w);
  Conn.placebos.stranger[,i] <- death.set.effect.Conn.gaps
  i <- i + 1
}

final.Conn.stranger <- cbind(Conn.placebos.stranger, Conn.gaps.stranger)
years <- seq(from=1995, to = 2018, by=1)


#### NJ Placebo Prep
NJ.placebos.stranger <- matrix(nrow = 21, ncol = 21)
i <- 1
for (s in c(2,3,4,5,7,9,11,12,13,14,16,18,19,20,21,22,23,25,26,27,28)) {
  controls <- c(2,3,4,5,7,9,11,12,13,14,16,18,19,20,21,22,23,25,26,27,28)
  controls.complete <- controls[controls!=s]
  death.set.effect.NJ <- dataprep(foo = death.set, time.predictors.prior = c(1995:2007), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nj.lag.1.stranger", "nj.lag.6.stranger", "nj.lag.12.stranger"), dependent = "stranger.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 
  synth.out.13 <- synth(data.prep.obj = death.set.effect.NJ, method = "All")
  death.set.effect.NJ.gaps <- death.set.effect.NJ$Y1plot - (death.set.effect.NJ$Y0plot %*% synth.out.13$solution.w);
  NJ.placebos.stranger[,i] <- death.set.effect.NJ.gaps
  i <- i + 1
}

final.NJ.stranger <- cbind(NJ.placebos.stranger, NJ.gaps.stranger)
years <- seq(from=1995, to = 2018, by=1)

#### Delaware Placebo Prep

Delaware.placebos.stranger <- matrix(nrow = 23, ncol = 21)
i <- 1
for (s in c(2,3,4,5,7,9,11,12,13,14,16,18,19,20,21,22,23,25,26,27,28)) {
  controls <- c(2,3,4,5,7,9,11,12,13,14,16,18,19,20,21,22,23,25,26,27,28)
  controls.complete <- controls[controls!=s]
  death.set.effect.Delaware.stranger <- dataprep(foo = death.set, time.predictors.prior = c(1996:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "del.lag.1.stranger", "del.lag.11.stranger", "del.lag.21.stranger"), dependent = "stranger.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1996:2016), time.plot = c(1996:2018)) 
  synth.out.14.stranger <- synth(data.prep.obj = death.set.effect.Delaware.stranger, method = "All")
  death.set.effect.Delaware.gaps.stranger <- death.set.effect.Delaware.stranger$Y1plot - (death.set.effect.Delaware.stranger$Y0plot %*% synth.out.14.stranger$solution.w);
  Delaware.placebos.stranger[,i] <- death.set.effect.Delaware.gaps.stranger
  i <- i + 1
}

final.Delaware.stranger <- cbind(Delaware.placebos.stranger, Delaware.gaps.stranger)
years.del <- seq(from=1996, to = 2018, by=1)

#### Maryland Placebo Prep


maryland.placebos.stranger <- matrix(nrow = 23, ncol = 21)
i <- 1
for (s in c(2,3,4,5,7,9,11,12,13,14,16,18,19,20,21,22,23,25,26,27,28)) {
  controls <- c(2,3,4,5,7,9,11,12,13,14,16,18,19,20,21,22,23,25,26,27,28)
  controls.complete <- controls[controls!=s]
  death.set.effect.maryland <- dataprep(foo = death.set, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "maryland.lag.1.stranger", "maryland.lag.9.stranger", "maryland.lag.18.stranger"), dependent = "stranger.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 
  synth.out.8 <- synth(data.prep.obj = death.set.effect.maryland, method = "All")
  death.set.maryland.gaps <- death.set.effect.maryland$Y1plot - (death.set.effect.maryland$Y0plot %*% synth.out.8$solution.w);
  maryland.placebos.stranger[,i] <- death.set.maryland.gaps
  i <- i + 1
}

final.maryland.stranger <- cbind(maryland.placebos.stranger, Maryland.gaps.stranger)
years <- seq(from=1995, to = 2018, by=1)


########################################
########## Permutation Calculations ##########
########################################

ny.pre.gaps.stranger <- final.ny.stranger[1:10,]
ny.post.gaps.stranger <- final.ny.stranger[11:nrow(final.ny.stranger),]

nm.pre.gaps.stranger <- final.NM.stranger[1:15,]
nm.post.gaps.stranger <- final.NM.stranger[16:nrow(final.NM.stranger),]

Illinois.pre.gaps.stranger <- final.Illinois.stranger[1:17,]
Illinois.post.gaps.stranger <- final.Illinois.stranger[18:nrow(final.Illinois.stranger),]

Conn.pre.gaps.stranger <- final.Conn.stranger[1:18,]
Conn.post.gaps.stranger <- final.Conn.stranger[19:nrow(final.Conn.stranger),]

NJ.pre.gaps.stranger <- final.NJ.stranger[1:13,]
NJ.post.gaps.stranger <- final.NJ.stranger[14:nrow(final.NJ.stranger),]

Delaware.pre.gaps.stranger <- final.Delaware.stranger[1:21,]
Delaware.post.gaps.stranger <- final.Delaware.stranger[22:nrow(final.Delaware.stranger),]

Maryland.pre.gaps.stranger <- final.maryland.stranger[1:19,]
Maryland.post.gaps.stranger <- final.maryland.stranger[20:nrow(final.maryland.stranger),]

diff.in.diff.ny.stranger <- colMeans(ny.post.gaps.stranger) - colMeans(ny.pre.gaps.stranger)
diff.in.diff.ny.placebo.stranger <- diff.in.diff.ny.stranger[1:(length(diff.in.diff.ny.stranger)-1)]
diff.in.diff.ny.actual.stranger <- diff.in.diff.ny.stranger[length(diff.in.diff.ny.stranger)]

diff.in.diff.nm.stranger <- colMeans(nm.post.gaps.stranger) - colMeans(nm.pre.gaps.stranger)
diff.in.diff.nm.placebo.stranger <- diff.in.diff.nm.stranger[1:(length(diff.in.diff.nm.stranger)-1)]
diff.in.diff.nm.actual.stranger <- diff.in.diff.nm.stranger[length(diff.in.diff.nm.stranger)]

diff.in.diff.Illinois.stranger <- colMeans(Illinois.post.gaps.stranger) - colMeans(Illinois.pre.gaps.stranger)
diff.in.diff.Illinois.placebo.stranger <- diff.in.diff.Illinois.stranger[1:(length(diff.in.diff.Illinois.stranger)-1)]
diff.in.diff.Illinois.actual.stranger <- diff.in.diff.Illinois.stranger[length(diff.in.diff.Illinois.stranger)]

diff.in.diff.Conn.stranger <- colMeans(Conn.post.gaps.stranger) - colMeans(Conn.pre.gaps.stranger)
diff.in.diff.Conn.placebo.stranger <- diff.in.diff.Conn.stranger[1:(length(diff.in.diff.Conn.stranger)-1)]
diff.in.diff.Conn.actual.stranger <- diff.in.diff.Conn.stranger[length(diff.in.diff.Conn.stranger)]

diff.in.diff.NJ.stranger <- colMeans(NJ.post.gaps.stranger) - colMeans(NJ.pre.gaps.stranger)
diff.in.diff.NJ.placebo.stranger <- diff.in.diff.NJ.stranger[1:(length(diff.in.diff.NJ.stranger)-1)]
diff.in.diff.NJ.actual.stranger <- diff.in.diff.NJ.stranger[length(diff.in.diff.NJ.stranger)]

diff.in.diff.Delaware.stranger <- colMeans(Delaware.post.gaps.stranger) - colMeans(Delaware.pre.gaps.stranger)
diff.in.diff.Delaware.placebo.stranger <- diff.in.diff.Delaware.stranger[1:(length(diff.in.diff.Delaware.stranger)-1)]
diff.in.diff.Delaware.actual.stranger <- diff.in.diff.Delaware.stranger[length(diff.in.diff.Delaware.stranger)]

diff.in.diff.Maryland.stranger <- colMeans(Maryland.post.gaps.stranger) - colMeans(Maryland.pre.gaps.stranger)
diff.in.diff.Maryland.placebo.stranger <- diff.in.diff.Maryland.stranger[1:(length(diff.in.diff.Maryland.stranger)-1)]
diff.in.diff.Maryland.actual.stranger <- diff.in.diff.Maryland.stranger[length(diff.in.diff.Maryland.stranger)]

exceeds.ny.stranger <- length(diff.in.diff.ny.placebo.stranger[diff.in.diff.ny.placebo.stranger>diff.in.diff.ny.actual.stranger])  
less.than.ny.stranger <- length(diff.in.diff.ny.placebo.stranger)-exceeds.ny.stranger

exceeds.nm.stranger <- length(diff.in.diff.nm.placebo.stranger[diff.in.diff.nm.placebo.stranger>diff.in.diff.nm.actual.stranger])  
less.than.nm.stranger <- length(diff.in.diff.nm.placebo.stranger)-exceeds.nm.stranger

exceeds.Illinois.stranger <- length(diff.in.diff.Illinois.placebo.stranger[diff.in.diff.Illinois.placebo.stranger>diff.in.diff.Illinois.actual.stranger])  
less.than.Illinois.stranger <- length(diff.in.diff.Illinois.placebo.stranger)-exceeds.Illinois.stranger

exceeds.Conn.stranger <- length(diff.in.diff.Conn.placebo.stranger[diff.in.diff.Conn.placebo.stranger>diff.in.diff.Conn.actual.stranger])  
less.than.Conn.stranger <- length(diff.in.diff.Conn.placebo.stranger)-exceeds.Conn.stranger

exceeds.NJ.stranger <- length(diff.in.diff.NJ.placebo.stranger[diff.in.diff.NJ.placebo.stranger>diff.in.diff.NJ.actual.stranger])  
less.than.NJ.stranger <- length(diff.in.diff.NJ.placebo.stranger)-exceeds.NJ.stranger

exceeds.Delaware.stranger <- length(diff.in.diff.Delaware.placebo.stranger[diff.in.diff.Delaware.placebo.stranger>diff.in.diff.Delaware.actual.stranger])  
less.than.Delaware.stranger <- length(diff.in.diff.Delaware.placebo.stranger)-exceeds.Delaware.stranger

exceeds.Maryland.stranger <- length(diff.in.diff.Maryland.placebo.stranger[diff.in.diff.Maryland.placebo.stranger>diff.in.diff.Maryland.actual.stranger])  
less.than.Maryland.stranger <- length(diff.in.diff.Maryland.placebo.stranger)-exceeds.Maryland.stranger

container.matrix.stranger <- matrix(nrow = 7, ncol = 5)
container.matrix.stranger[1,] <- c("New York", round(diff.in.diff.ny.actual.stranger, 2), exceeds.ny.stranger, less.than.ny.stranger, round((exceeds.ny.stranger/21), 2))
container.matrix.stranger[2,] <- c("New Mexico", round(diff.in.diff.nm.actual.stranger, 2), exceeds.nm.stranger, less.than.nm.stranger, round((exceeds.nm.stranger/21), 2))
container.matrix.stranger[3,] <- c("Illinois", round(diff.in.diff.Illinois.actual.stranger, 2), exceeds.Illinois.stranger, less.than.Illinois.stranger, round((exceeds.Illinois.stranger/21), 2))
container.matrix.stranger[4,] <- c("Connecticut", round(diff.in.diff.Conn.actual.stranger, 2), exceeds.Conn.stranger, less.than.Conn.stranger, round((exceeds.Conn.stranger/21), 2))
container.matrix.stranger[5,] <- c("New Jersey", round(diff.in.diff.NJ.actual.stranger, 2), exceeds.NJ.stranger, less.than.NJ.stranger, round((exceeds.NJ.stranger/21), 2))
container.matrix.stranger[6,] <- c("Delaware", round(diff.in.diff.Delaware.actual.stranger, 2), exceeds.Delaware.stranger, less.than.Delaware.stranger, round((exceeds.Delaware.stranger/21), 2))
container.matrix.stranger[7,] <- c("Maryland", round(diff.in.diff.Maryland.actual.stranger, 2), exceeds.Maryland.stranger, less.than.Maryland.stranger, round((exceeds.Maryland.stranger/21), 2))


########################################
##### Acquaintance Homicide Rates #########
########################################


### New York 

new.york.effect.acquaintance <- dataprep(foo = NY.Set, time.predictors.prior = c(1995:2004), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "ny.lag.1.acquaintance", "ny.lag.5.acquaintance", "ny.lag.9.acquaintance"), dependent = "acquaintance.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 36, controls.identifier = c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 

synth.out.acquaintance <- synth(data.prep.obj = new.york.effect.acquaintance, method = "All")

ny.tables.acquaintance <- synth.tab(dataprep.res = new.york.effect.acquaintance, synth.res = synth.out.acquaintance)

ny.gaps.acquaintance <- new.york.effect.acquaintance$Y1plot - (new.york.effect.acquaintance$Y0plot %*% synth.out.acquaintance$solution.w)


### New Mexico

nm.effect.acquaintance <- dataprep(foo = NM.Set, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nm.lag.1.acquaintance", "nm.lag.7.acquaintance", "nm.lag.14.acquaintance"), dependent = "acquaintance.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 40, controls.identifier = c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 

synth.out.2.acquaintance <- synth(data.prep.obj = nm.effect.acquaintance, method = "All")

nm.tables.acquaintance <- synth.tab(dataprep.res = nm.effect.acquaintance, synth.res = synth.out.2.acquaintance)

nm.gaps.acquaintance <- nm.effect.acquaintance$Y1plot - (nm.effect.acquaintance$Y0plot %*% synth.out.2.acquaintance$solution.w)


### Illinois 

Illinois.effect.acquaintance <- dataprep(foo = Illinois.Set, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "illinois.lag.1.acquaintance", "illinois.lag.8.acquaintance", "illinois.lag.16.acquaintance"), dependent = "acquaintance.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 39, controls.identifier = c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 

synth.out.3.acquaintance <- synth(data.prep.obj = Illinois.effect.acquaintance, method = "All")

Illinois.tables.acquaintance <- synth.tab(dataprep.res = Illinois.effect.acquaintance, synth.res = synth.out.3.acquaintance)

Illinois.gaps.acquaintance <- Illinois.effect.acquaintance$Y1plot - (Illinois.effect.acquaintance$Y0plot %*% synth.out.3.acquaintance$solution.w)


### Connecticut

Conn.effect.acquaintance <- dataprep(foo = Conn.Set, time.predictors.prior = c(1995:2012), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "conn.lag.1.acquaintance", "conn.lag.9.acquaintance", "conn.lag.17.acquaintance"), dependent = "acquaintance.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 41, controls.identifier = c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 

synth.out.4.acquaintance <- synth(data.prep.obj = Conn.effect.acquaintance, method = "All")

Conn.tables.acquaintance <- synth.tab(dataprep.res = Conn.effect.acquaintance, synth.res = synth.out.4.acquaintance)

Conn.gaps.acquaintance <- Conn.effect.acquaintance$Y1plot - (Conn.effect.acquaintance$Y0plot %*% synth.out.4.acquaintance$solution.w)


### New Jersey

NJ.effect.acquaintance <- dataprep(foo = NJ.Set, time.predictors.prior = c(1995:2007), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nj.lag.1.acquaintance", "nj.lag.6.acquaintance", "nj.lag.12.acquaintance"), dependent = "acquaintance.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 42, controls.identifier = c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 

synth.out.5.acquaintance  <- synth(data.prep.obj = NJ.effect.acquaintance, method = "All")

NJ.tables.acquaintance <- synth.tab(dataprep.res = NJ.effect.acquaintance, synth.res = synth.out.5.acquaintance)

NJ.gaps.acquaintance <- NJ.effect.acquaintance$Y1plot - (NJ.effect.acquaintance$Y0plot %*% synth.out.5.acquaintance$solution.w)

### Delaware

Delaware.effect.acquaintance <- dataprep(foo = Delaware.Set, time.predictors.prior = c(1996:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "del.lag.1.acquaintance", "del.lag.11.acquaintance", "del.lag.21.acquaintance"), dependent = "acquaintance.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 38, controls.identifier = c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29), time.optimize.ssr = c(1996:2016), time.plot = c(1996:2018)) 

synth.out.6.acquaintance <- synth(data.prep.obj = Delaware.effect.acquaintance, method = "All")

Delaware.gaps.acquaintance <- Delaware.effect.acquaintance$Y1plot - (Delaware.effect.acquaintance$Y0plot %*% synth.out.6.acquaintance$solution.w)

### Maryland

Maryland.effect.acquaintance <- dataprep(foo = Maryland.Set, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "maryland.lag.1.acquaintance", "maryland.lag.9.acquaintance", "maryland.lag.18.acquaintance"), dependent = "acquaintance.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 37, controls.identifier = c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 

synth.out.7.acquaintance <- synth(data.prep.obj = Maryland.effect.acquaintance, method = "All")

Maryland.tables.acquaintance <- synth.tab(dataprep.res = Maryland.effect.acquaintance, synth.res = synth.out.7.acquaintance)

Maryland.gaps.acquaintance <- Maryland.effect.acquaintance$Y1plot - (Maryland.effect.acquaintance$Y0plot %*% synth.out.7.acquaintance$solution.w)


########################################
###### Adding to Placebo Gap Analysis ############
########################################

#### NY Placebo Prep
ny.placebos.acquaintance <- matrix(nrow = 21, ncol = 24)
i <- 1
for (s in c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)) {
  controls <- c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)
  controls.complete <- controls[controls!=s]
  death.set.effect.ny <- dataprep(foo = death.set, time.predictors.prior = c(1995:2004), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "ny.lag.1.acquaintance", "ny.lag.5.acquaintance", "ny.lag.9.acquaintance"), dependent = "acquaintance.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 
  synth.out.9 <- synth(data.prep.obj = death.set.effect.ny, method = "All")
  death.set.effect.ny.gaps <- death.set.effect.ny$Y1plot - (death.set.effect.ny$Y0plot %*% synth.out.9$solution.w);
  ny.placebos.acquaintance[,i] <- death.set.effect.ny.gaps
  i <- i + 1
}

final.ny.acquaintance <- cbind(ny.placebos.acquaintance, ny.gaps.acquaintance)
years <- seq(from=1995, to = 2018, by=1)

#### NM Placebo Prep
NM.placebos.acquaintance <- matrix(nrow = 21, ncol = 24)
i <- 1
for (s in c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)) {
  controls <- c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NM <- dataprep(foo = death.set, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nm.lag.1.acquaintance", "nm.lag.7.acquaintance", "nm.lag.14.acquaintance"), dependent = "acquaintance.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 
  synth.out.10 <- synth(data.prep.obj = death.set.effect.NM, method = "All")
  death.set.effect.nm.gaps <- death.set.effect.NM$Y1plot - (death.set.effect.NM$Y0plot %*% synth.out.10$solution.w);
  NM.placebos.acquaintance[,i] <- death.set.effect.nm.gaps
  i <- i + 1
}

final.NM.acquaintance <- cbind(NM.placebos.acquaintance, nm.gaps.acquaintance)
years <- seq(from=1995, to = 2018, by=1)


#### Illinois Placebo Prep
Illinois.placebos.acquaintance <- matrix(nrow = 23, ncol = 24)
i <- 1
for (s in c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)) {
  controls <- c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Illinois <- dataprep(foo = death.set, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "illinois.lag.1.acquaintance", "illinois.lag.8.acquaintance", "illinois.lag.16.acquaintance"), dependent = "acquaintance.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 
  synth.out.11 <- synth(data.prep.obj = death.set.effect.Illinois, method = "All")
  death.set.effect.Illinois.gaps <- death.set.effect.Illinois$Y1plot - (death.set.effect.Illinois$Y0plot %*% synth.out.11$solution.w);
  Illinois.placebos.acquaintance[,i] <- death.set.effect.Illinois.gaps
  i <- i + 1
}

final.Illinois.acquaintance <- cbind(Illinois.placebos.acquaintance, Illinois.gaps.acquaintance)
years <- seq(from=1995, to = 2018, by=1)


#### Conn Placebo Prep
Conn.placebos.acquaintance <- matrix(nrow = 23, ncol = 24)
i <- 1
for (s in c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)) {
  controls <- c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Conn <- dataprep(foo = death.set, time.predictors.prior = c(1995:2012), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "conn.lag.1.acquaintance", "conn.lag.9.acquaintance", "conn.lag.17.acquaintance"), dependent = "acquaintance.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 
  synth.out.12 <- synth(data.prep.obj = death.set.effect.Conn, method = "All")
  death.set.effect.Conn.gaps <- death.set.effect.Conn$Y1plot - (death.set.effect.Conn$Y0plot %*% synth.out.12$solution.w);
  Conn.placebos.acquaintance[,i] <- death.set.effect.Conn.gaps
  i <- i + 1
}

final.Conn.acquaintance <- cbind(Conn.placebos.acquaintance, Conn.gaps.acquaintance)
years <- seq(from=1995, to = 2018, by=1)


#### NJ Placebo Prep
NJ.placebos.acquaintance <- matrix(nrow = 21, ncol = 24)
i <- 1
for (s in c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)) {
  controls <- c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NJ <- dataprep(foo = death.set, time.predictors.prior = c(1995:2007), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nj.lag.1.acquaintance", "nj.lag.6.acquaintance", "nj.lag.12.acquaintance"), dependent = "acquaintance.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 
  synth.out.13 <- synth(data.prep.obj = death.set.effect.NJ, method = "All")
  death.set.effect.NJ.gaps <- death.set.effect.NJ$Y1plot - (death.set.effect.NJ$Y0plot %*% synth.out.13$solution.w);
  NJ.placebos.acquaintance[,i] <- death.set.effect.NJ.gaps
  i <- i + 1
}

final.NJ.acquaintance <- cbind(NJ.placebos.acquaintance, NJ.gaps.acquaintance)
years <- seq(from=1995, to = 2018, by=1)

#### Delaware Placebo Prep

Delaware.placebos.acquaintance <- matrix(nrow = 23, ncol = 24)
i <- 1
for (s in c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)) {
  controls <- c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Delaware.acquaintance <- dataprep(foo = death.set, time.predictors.prior = c(1996:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "del.lag.1.acquaintance", "del.lag.11.acquaintance", "del.lag.21.acquaintance"), dependent = "acquaintance.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1996:2016), time.plot = c(1996:2018)) 
  synth.out.14.acquaintance <- synth(data.prep.obj = death.set.effect.Delaware.acquaintance, method = "All")
  death.set.effect.Delaware.gaps.acquaintance <- death.set.effect.Delaware.acquaintance$Y1plot - (death.set.effect.Delaware.acquaintance$Y0plot %*% synth.out.14.acquaintance$solution.w);
  Delaware.placebos.acquaintance[,i] <- death.set.effect.Delaware.gaps.acquaintance
  i <- i + 1
}

final.Delaware.acquaintance <- cbind(Delaware.placebos.acquaintance, Delaware.gaps.acquaintance)
years.del <- seq(from=1996, to = 2018, by=1)

#### Maryland Placebo Prep


maryland.placebos.acquaintance <- matrix(nrow = 23, ncol = 24)
i <- 1
for (s in c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)) {
  controls <- c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)
  controls.complete <- controls[controls!=s]
  death.set.effect.maryland <- dataprep(foo = death.set, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "maryland.lag.1.acquaintance", "maryland.lag.9.acquaintance", "maryland.lag.18.acquaintance"), dependent = "acquaintance.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 
  synth.out.8 <- synth(data.prep.obj = death.set.effect.maryland, method = "All")
  death.set.maryland.gaps <- death.set.effect.maryland$Y1plot - (death.set.effect.maryland$Y0plot %*% synth.out.8$solution.w);
  maryland.placebos.acquaintance[,i] <- death.set.maryland.gaps
  i <- i + 1
}

final.maryland.acquaintance <- cbind(maryland.placebos.acquaintance, Maryland.gaps.acquaintance)
years <- seq(from=1995, to = 2018, by=1)


########################################
########## Permutation Calculations ##########
########################################

ny.pre.gaps.acquaintance <- final.ny.acquaintance[1:10,]
ny.post.gaps.acquaintance <- final.ny.acquaintance[11:nrow(final.ny.acquaintance),]

nm.pre.gaps.acquaintance <- final.NM.acquaintance[1:15,]
nm.post.gaps.acquaintance <- final.NM.acquaintance[16:nrow(final.NM.acquaintance),]

Illinois.pre.gaps.acquaintance <- final.Illinois.acquaintance[1:17,]
Illinois.post.gaps.acquaintance <- final.Illinois.acquaintance[18:nrow(final.Illinois.acquaintance),]

Conn.pre.gaps.acquaintance <- final.Conn.acquaintance[1:18,]
Conn.post.gaps.acquaintance <- final.Conn.acquaintance[19:nrow(final.Conn.acquaintance),]

NJ.pre.gaps.acquaintance <- final.NJ.acquaintance[1:13,]
NJ.post.gaps.acquaintance <- final.NJ.acquaintance[14:nrow(final.NJ.acquaintance),]

Delaware.pre.gaps.acquaintance <- final.Delaware.acquaintance[1:21,]
Delaware.post.gaps.acquaintance <- final.Delaware.acquaintance[22:nrow(final.Delaware.acquaintance),]

Maryland.pre.gaps.acquaintance <- final.maryland.acquaintance[1:19,]
Maryland.post.gaps.acquaintance <- final.maryland.acquaintance[20:nrow(final.maryland.acquaintance),]

diff.in.diff.ny.acquaintance <- colMeans(ny.post.gaps.acquaintance) - colMeans(ny.pre.gaps.acquaintance)
diff.in.diff.ny.placebo.acquaintance <- diff.in.diff.ny.acquaintance[1:(length(diff.in.diff.ny.acquaintance)-1)]
diff.in.diff.ny.actual.acquaintance <- diff.in.diff.ny.acquaintance[length(diff.in.diff.ny.acquaintance)]

diff.in.diff.nm.acquaintance <- colMeans(nm.post.gaps.acquaintance) - colMeans(nm.pre.gaps.acquaintance)
diff.in.diff.nm.placebo.acquaintance <- diff.in.diff.nm.acquaintance[1:(length(diff.in.diff.nm.acquaintance)-1)]
diff.in.diff.nm.actual.acquaintance <- diff.in.diff.nm.acquaintance[length(diff.in.diff.nm.acquaintance)]

diff.in.diff.Illinois.acquaintance <- colMeans(Illinois.post.gaps.acquaintance) - colMeans(Illinois.pre.gaps.acquaintance)
diff.in.diff.Illinois.placebo.acquaintance <- diff.in.diff.Illinois.acquaintance[1:(length(diff.in.diff.Illinois.acquaintance)-1)]
diff.in.diff.Illinois.actual.acquaintance <- diff.in.diff.Illinois.acquaintance[length(diff.in.diff.Illinois.acquaintance)]

diff.in.diff.Conn.acquaintance <- colMeans(Conn.post.gaps.acquaintance) - colMeans(Conn.pre.gaps.acquaintance)
diff.in.diff.Conn.placebo.acquaintance <- diff.in.diff.Conn.acquaintance[1:(length(diff.in.diff.Conn.acquaintance)-1)]
diff.in.diff.Conn.actual.acquaintance <- diff.in.diff.Conn.acquaintance[length(diff.in.diff.Conn.acquaintance)]

diff.in.diff.NJ.acquaintance <- colMeans(NJ.post.gaps.acquaintance) - colMeans(NJ.pre.gaps.acquaintance)
diff.in.diff.NJ.placebo.acquaintance <- diff.in.diff.NJ.acquaintance[1:(length(diff.in.diff.NJ.acquaintance)-1)]
diff.in.diff.NJ.actual.acquaintance <- diff.in.diff.NJ.acquaintance[length(diff.in.diff.NJ.acquaintance)]

diff.in.diff.Delaware.acquaintance <- colMeans(Delaware.post.gaps.acquaintance) - colMeans(Delaware.pre.gaps.acquaintance)
diff.in.diff.Delaware.placebo.acquaintance <- diff.in.diff.Delaware.acquaintance[1:(length(diff.in.diff.Delaware.acquaintance)-1)]
diff.in.diff.Delaware.actual.acquaintance <- diff.in.diff.Delaware.acquaintance[length(diff.in.diff.Delaware.acquaintance)]

diff.in.diff.Maryland.acquaintance <- colMeans(Maryland.post.gaps.acquaintance) - colMeans(Maryland.pre.gaps.acquaintance)
diff.in.diff.Maryland.placebo.acquaintance <- diff.in.diff.Maryland.acquaintance[1:(length(diff.in.diff.Maryland.acquaintance)-1)]
diff.in.diff.Maryland.actual.acquaintance <- diff.in.diff.Maryland.acquaintance[length(diff.in.diff.Maryland.acquaintance)]

exceeds.ny.acquaintance <- length(diff.in.diff.ny.placebo.acquaintance[diff.in.diff.ny.placebo.acquaintance>diff.in.diff.ny.actual.acquaintance])  
less.than.ny.acquaintance <- length(diff.in.diff.ny.placebo.acquaintance)-exceeds.ny.acquaintance

exceeds.nm.acquaintance <- length(diff.in.diff.nm.placebo.acquaintance[diff.in.diff.nm.placebo.acquaintance>diff.in.diff.nm.actual.acquaintance])  
less.than.nm.acquaintance <- length(diff.in.diff.nm.placebo.acquaintance)-exceeds.nm.acquaintance

exceeds.Illinois.acquaintance <- length(diff.in.diff.Illinois.placebo.acquaintance[diff.in.diff.Illinois.placebo.acquaintance>diff.in.diff.Illinois.actual.acquaintance])  
less.than.Illinois.acquaintance <- length(diff.in.diff.Illinois.placebo.acquaintance)-exceeds.Illinois.acquaintance

exceeds.Conn.acquaintance <- length(diff.in.diff.Conn.placebo.acquaintance[diff.in.diff.Conn.placebo.acquaintance>diff.in.diff.Conn.actual.acquaintance])  
less.than.Conn.acquaintance <- length(diff.in.diff.Conn.placebo.acquaintance)-exceeds.Conn.acquaintance

exceeds.NJ.acquaintance <- length(diff.in.diff.NJ.placebo.acquaintance[diff.in.diff.NJ.placebo.acquaintance>diff.in.diff.NJ.actual.acquaintance])  
less.than.NJ.acquaintance <- length(diff.in.diff.NJ.placebo.acquaintance)-exceeds.NJ.acquaintance

exceeds.Delaware.acquaintance <- length(diff.in.diff.Delaware.placebo.acquaintance[diff.in.diff.Delaware.placebo.acquaintance>diff.in.diff.Delaware.actual.acquaintance])  
less.than.Delaware.acquaintance <- length(diff.in.diff.Delaware.placebo.acquaintance)-exceeds.Delaware.acquaintance

exceeds.Maryland.acquaintance <- length(diff.in.diff.Maryland.placebo.acquaintance[diff.in.diff.Maryland.placebo.acquaintance>diff.in.diff.Maryland.actual.acquaintance])  
less.than.Maryland.acquaintance <- length(diff.in.diff.Maryland.placebo.acquaintance)-exceeds.Maryland.acquaintance

container.matrix.acquaintance <- matrix(nrow = 7, ncol = 5)
container.matrix.acquaintance[1,] <- c("New York", round(diff.in.diff.ny.actual.acquaintance, 2), exceeds.ny.acquaintance, less.than.ny.acquaintance, round((exceeds.ny.acquaintance/21), 2))
container.matrix.acquaintance[2,] <- c("New Mexico", round(diff.in.diff.nm.actual.acquaintance, 2), exceeds.nm.acquaintance, less.than.nm.acquaintance, round((exceeds.nm.acquaintance/21), 2))
container.matrix.acquaintance[3,] <- c("Illinois", round(diff.in.diff.Illinois.actual.acquaintance, 2), exceeds.Illinois.acquaintance, less.than.Illinois.acquaintance, round((exceeds.Illinois.acquaintance/21), 2))
container.matrix.acquaintance[4,] <- c("Connecticut", round(diff.in.diff.Conn.actual.acquaintance, 2), exceeds.Conn.acquaintance, less.than.Conn.acquaintance, round((exceeds.Conn.acquaintance/21), 2))
container.matrix.acquaintance[5,] <- c("New Jersey", round(diff.in.diff.NJ.actual.acquaintance, 2), exceeds.NJ.acquaintance, less.than.NJ.acquaintance, round((exceeds.NJ.acquaintance/21), 2))
container.matrix.acquaintance[6,] <- c("Delaware", round(diff.in.diff.Delaware.actual.acquaintance, 2), exceeds.Delaware.acquaintance, less.than.Delaware.acquaintance, round((exceeds.Delaware.acquaintance/21), 2))
container.matrix.acquaintance[7,] <- c("Maryland", round(diff.in.diff.Maryland.actual.acquaintance, 2), exceeds.Maryland.acquaintance, less.than.Maryland.acquaintance, round((exceeds.Maryland.acquaintance/21), 2))



########################################
##### Intimate Homicide Rates #########
########################################


### New York 

new.york.effect.intimate <- dataprep(foo = NY.Set, time.predictors.prior = c(1995:2004), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "ny.lag.1.intimate", "ny.lag.5.intimate", "ny.lag.9.intimate"), dependent = "intimate.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 36, controls.identifier = c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 

synth.out.intimate <- synth(data.prep.obj = new.york.effect.intimate, method = "All")

ny.tables.intimate <- synth.tab(dataprep.res = new.york.effect.intimate, synth.res = synth.out.intimate)

path.plot(synth.res = synth.out.intimate, dataprep.res = new.york.effect.intimate, Ylab = "Intimate Homicide Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004)

ny.gaps.intimate <- new.york.effect.intimate$Y1plot - (new.york.effect.intimate$Y0plot %*% synth.out.intimate$solution.w)


### New Mexico

nm.effect.intimate <- dataprep(foo = NM.Set, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nm.lag.1.intimate", "nm.lag.7.intimate", "nm.lag.14.intimate"), dependent = "intimate.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 40, controls.identifier = c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 

synth.out.2.intimate <- synth(data.prep.obj = nm.effect.intimate, method = "All")

nm.tables.intimate <- synth.tab(dataprep.res = nm.effect.intimate, synth.res = synth.out.2.intimate)


path.plot(synth.res = synth.out.2.intimate, dataprep.res = nm.effect.intimate, Ylab = "Intimate Homicide Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009)

nm.gaps.intimate <- nm.effect.intimate$Y1plot - (nm.effect.intimate$Y0plot %*% synth.out.2.intimate$solution.w)


### Illinois 

Illinois.effect.intimate <- dataprep(foo = Illinois.Set, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "illinois.lag.1.intimate", "illinois.lag.8.intimate", "illinois.lag.16.intimate"), dependent = "intimate.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 39, controls.identifier = c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 

synth.out.3.intimate <- synth(data.prep.obj = Illinois.effect.intimate, method = "All")

Illinois.tables.intimate <- synth.tab(dataprep.res = Illinois.effect.intimate, synth.res = synth.out.3.intimate)

path.plot(synth.res = synth.out.3.intimate, dataprep.res = Illinois.effect.intimate, Ylab = "Intimate Homicide Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011)

Illinois.gaps.intimate <- Illinois.effect.intimate$Y1plot - (Illinois.effect.intimate$Y0plot %*% synth.out.3.intimate$solution.w)


### Connecticut

Conn.effect.intimate <- dataprep(foo = Conn.Set, time.predictors.prior = c(1995:2012), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "conn.lag.1.intimate", "conn.lag.9.intimate", "conn.lag.17.intimate"), dependent = "intimate.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 41, controls.identifier = c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 

synth.out.4.intimate <- synth(data.prep.obj = Conn.effect.intimate, method = "All")

Conn.tables.intimate <- synth.tab(dataprep.res = Conn.effect.intimate, synth.res = synth.out.4.intimate)

path.plot(synth.res = synth.out.4.intimate, dataprep.res = Conn.effect.intimate, Ylab = "Intimate Homicide Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012)

Conn.gaps.intimate <- Conn.effect.intimate$Y1plot - (Conn.effect.intimate$Y0plot %*% synth.out.4.intimate$solution.w)


### New Jersey

NJ.effect.intimate <- dataprep(foo = NJ.Set, time.predictors.prior = c(1995:2007), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nj.lag.1.intimate", "nj.lag.6.intimate", "nj.lag.12.intimate"), dependent = "intimate.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 42, controls.identifier = c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 

synth.out.5.intimate  <- synth(data.prep.obj = NJ.effect.intimate, method = "All")

NJ.tables.intimate <- synth.tab(dataprep.res = NJ.effect.intimate, synth.res = synth.out.5.intimate)

path.plot(synth.res = synth.out.5.intimate, dataprep.res = NJ.effect.intimate, Ylab = "Intimate Homicide Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007)

NJ.gaps.intimate <- NJ.effect.intimate$Y1plot - (NJ.effect.intimate$Y0plot %*% synth.out.5.intimate$solution.w)

### Delaware

Delaware.effect.intimate <- dataprep(foo = Delaware.Set, time.predictors.prior = c(1996:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "del.lag.1.intimate", "del.lag.11.intimate", "del.lag.21.intimate"), dependent = "intimate.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 38, controls.identifier = c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29), time.optimize.ssr = c(1996:2016), time.plot = c(1996:2018)) 

synth.out.6.intimate <- synth(data.prep.obj = Delaware.effect.intimate, method = "All")

path.plot(synth.res = synth.out.6.intimate, dataprep.res = Delaware.effect.intimate, Ylab = "Intimate Homicide Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016)

Delaware.gaps.intimate <- Delaware.effect.intimate$Y1plot - (Delaware.effect.intimate$Y0plot %*% synth.out.6.intimate$solution.w)

### Maryland

Maryland.effect.intimate <- dataprep(foo = Maryland.Set, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "maryland.lag.1.intimate", "maryland.lag.9.intimate", "maryland.lag.18.intimate"), dependent = "intimate.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 37, controls.identifier = c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 

synth.out.7.intimate <- synth(data.prep.obj = Maryland.effect.intimate, method = "All")

path.plot(synth.res = synth.out.7.intimate, dataprep.res = Maryland.effect.intimate, Ylab = "Intimate Homicide Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013)

Maryland.tables.intimate <- synth.tab(dataprep.res = Maryland.effect.intimate, synth.res = synth.out.7.intimate)

Maryland.gaps.intimate <- Maryland.effect.intimate$Y1plot - (Maryland.effect.intimate$Y0plot %*% synth.out.7.intimate$solution.w)



############### ############### ############### 
############### Single Plot ###############
############### ############### ############### 



### New York 

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))
path.plot(synth.res = synth.out.intimate, dataprep.res = new.york.effect.intimate, Ylab = "Intimate Homicide Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004, col = "red")

### New Mexico


path.plot(synth.res = synth.out.2.intimate, dataprep.res = nm.effect.intimate, Ylab = "Intimate Homicide Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009, col = "red")
mtext("Figure 5: Synthetic Control Plots for States That Eliminated Capital Punishment (y = Intimate Murders Per 100,000 Residents)", side = 3, line = 4, font = 2)

### Illinois 


path.plot(synth.res = synth.out.3.intimate, dataprep.res = Illinois.effect.intimate, Ylab = "Intimate Homicide Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011, col = "red")



### Connecticut


path.plot(synth.res = synth.out.4.intimate, dataprep.res = Conn.effect.intimate, Ylab = "Intimate Homicide Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012, col = "red")


### New Jersey


path.plot(synth.res = synth.out.5.intimate, dataprep.res = NJ.effect.intimate, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007, col = "red")

### Delaware

path.plot(synth.res = synth.out.6.intimate, dataprep.res = Delaware.effect.intimate, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016, col = "red")


### Maryland

path.plot(synth.res = synth.out.7.intimate, dataprep.res = Maryland.effect.intimate, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013, col = "red")

legend.cols <- c("black", "black", "red")
names(legend.cols) <- c("Treated", "Synthetic Control", "Year Eliminated DP")
par(fig= c(0, 1, 0, 1), oma = c(0,0,0,0), mar = c(.5, .5, .5, .5), new=TRUE)
plot(0,0, type = "n", bty="n", xaxt ="n", yaxt="n")
legend("bottom", text.width=c(0.3,0.3,0.3), legend=names(legend.cols), col = legend.cols, lty = c(1,2,1), lwd = c(2.5, 2.5, 2.5), cex = .75, xpd = TRUE, horiz = F, inset = c(0,0,0), bty = "y", text.font = 2)


########################################
###### Adding to Placebo Gap Analysis ############
########################################

#### NY Placebo Prep
ny.placebos.intimate <- matrix(nrow = 21, ncol = 24)
i <- 1
for (s in c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)) {
  controls <- c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)
  controls.complete <- controls[controls!=s]
  death.set.effect.ny <- dataprep(foo = death.set, time.predictors.prior = c(1995:2004), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "ny.lag.1.intimate", "ny.lag.5.intimate", "ny.lag.9.intimate"), dependent = "intimate.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 
  synth.out.9 <- synth(data.prep.obj = death.set.effect.ny, method = "All")
  death.set.effect.ny.gaps <- death.set.effect.ny$Y1plot - (death.set.effect.ny$Y0plot %*% synth.out.9$solution.w);
  ny.placebos.intimate[,i] <- death.set.effect.ny.gaps
  i <- i + 1
}

final.ny.intimate <- cbind(ny.placebos.intimate, ny.gaps.intimate)
years <- seq(from=1995, to = 2018, by=1)

#### NM Placebo Prep
NM.placebos.intimate <- matrix(nrow = 21, ncol = 24)
i <- 1
for (s in c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)) {
  controls <- c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NM <- dataprep(foo = death.set, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nm.lag.1.intimate", "nm.lag.7.intimate", "nm.lag.14.intimate"), dependent = "intimate.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 
  synth.out.10 <- synth(data.prep.obj = death.set.effect.NM, method = "All")
  death.set.effect.nm.gaps <- death.set.effect.NM$Y1plot - (death.set.effect.NM$Y0plot %*% synth.out.10$solution.w);
  NM.placebos.intimate[,i] <- death.set.effect.nm.gaps
  i <- i + 1
}

final.NM.intimate <- cbind(NM.placebos.intimate, nm.gaps.intimate)
years <- seq(from=1995, to = 2018, by=1)


#### Illinois Placebo Prep
Illinois.placebos.intimate <- matrix(nrow = 23, ncol = 24)
i <- 1
for (s in c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)) {
  controls <- c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Illinois <- dataprep(foo = death.set, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "illinois.lag.1.intimate", "illinois.lag.8.intimate", "illinois.lag.16.intimate"), dependent = "intimate.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 
  synth.out.11 <- synth(data.prep.obj = death.set.effect.Illinois, method = "All")
  death.set.effect.Illinois.gaps <- death.set.effect.Illinois$Y1plot - (death.set.effect.Illinois$Y0plot %*% synth.out.11$solution.w);
  Illinois.placebos.intimate[,i] <- death.set.effect.Illinois.gaps
  i <- i + 1
}

final.Illinois.intimate <- cbind(Illinois.placebos.intimate, Illinois.gaps.intimate)
years <- seq(from=1995, to = 2018, by=1)


#### Conn Placebo Prep
Conn.placebos.intimate <- matrix(nrow = 23, ncol = 24)
i <- 1
for (s in c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)) {
  controls <- c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Conn <- dataprep(foo = death.set, time.predictors.prior = c(1995:2012), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "conn.lag.1.intimate", "conn.lag.9.intimate", "conn.lag.17.intimate"), dependent = "intimate.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 
  synth.out.12 <- synth(data.prep.obj = death.set.effect.Conn, method = "All")
  death.set.effect.Conn.gaps <- death.set.effect.Conn$Y1plot - (death.set.effect.Conn$Y0plot %*% synth.out.12$solution.w);
  Conn.placebos.intimate[,i] <- death.set.effect.Conn.gaps
  i <- i + 1
}

final.Conn.intimate <- cbind(Conn.placebos.intimate, Conn.gaps.intimate)
years <- seq(from=1995, to = 2018, by=1)


#### NJ Placebo Prep
NJ.placebos.intimate <- matrix(nrow = 21, ncol = 24)
i <- 1
for (s in c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)) {
  controls <- c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NJ <- dataprep(foo = death.set, time.predictors.prior = c(1995:2007), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nj.lag.1.intimate", "nj.lag.6.intimate", "nj.lag.12.intimate"), dependent = "intimate.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 
  synth.out.13 <- synth(data.prep.obj = death.set.effect.NJ, method = "All")
  death.set.effect.NJ.gaps <- death.set.effect.NJ$Y1plot - (death.set.effect.NJ$Y0plot %*% synth.out.13$solution.w);
  NJ.placebos.intimate[,i] <- death.set.effect.NJ.gaps
  i <- i + 1
}

final.NJ.intimate <- cbind(NJ.placebos.intimate, NJ.gaps.intimate)
years <- seq(from=1995, to = 2018, by=1)

#### Delaware Placebo Prep

Delaware.placebos.intimate <- matrix(nrow = 23, ncol = 24)
i <- 1
for (s in c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)) {
  controls <- c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Delaware.intimate <- dataprep(foo = death.set, time.predictors.prior = c(1996:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "del.lag.1.intimate", "del.lag.11.intimate", "del.lag.21.intimate"), dependent = "intimate.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1996:2016), time.plot = c(1996:2018)) 
  synth.out.14.intimate <- synth(data.prep.obj = death.set.effect.Delaware.intimate, method = "All")
  death.set.effect.Delaware.gaps.intimate <- death.set.effect.Delaware.intimate$Y1plot - (death.set.effect.Delaware.intimate$Y0plot %*% synth.out.14.intimate$solution.w);
  Delaware.placebos.intimate[,i] <- death.set.effect.Delaware.gaps.intimate
  i <- i + 1
}

final.Delaware.intimate <- cbind(Delaware.placebos.intimate, Delaware.gaps.intimate)
years.del <- seq(from=1996, to = 2018, by=1)

#### Maryland Placebo Prep


maryland.placebos.intimate <- matrix(nrow = 23, ncol = 24)
i <- 1
for (s in c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)) {
  controls <- c(2,3,4,5,7,8,9,11,12,13,14,16,18,19,20,21,22,23,24,25,26,27,28,29)
  controls.complete <- controls[controls!=s]
  death.set.effect.maryland <- dataprep(foo = death.set, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "maryland.lag.1.intimate", "maryland.lag.9.intimate", "maryland.lag.18.intimate"), dependent = "intimate.homicide.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 
  synth.out.8 <- synth(data.prep.obj = death.set.effect.maryland, method = "All")
  death.set.maryland.gaps <- death.set.effect.maryland$Y1plot - (death.set.effect.maryland$Y0plot %*% synth.out.8$solution.w);
  maryland.placebos.intimate[,i] <- death.set.maryland.gaps
  i <- i + 1
}

final.maryland.intimate <- cbind(maryland.placebos.intimate, Maryland.gaps.intimate)
years <- seq(from=1995, to = 2018, by=1)


########################################
########## Permutation Calculations ##########
########################################

ny.pre.gaps.intimate <- final.ny.intimate[1:10,]
ny.post.gaps.intimate <- final.ny.intimate[11:nrow(final.ny.intimate),]

nm.pre.gaps.intimate <- final.NM.intimate[1:15,]
nm.post.gaps.intimate <- final.NM.intimate[16:nrow(final.NM.intimate),]

Illinois.pre.gaps.intimate <- final.Illinois.intimate[1:17,]
Illinois.post.gaps.intimate <- final.Illinois.intimate[18:nrow(final.Illinois.intimate),]

Conn.pre.gaps.intimate <- final.Conn.intimate[1:18,]
Conn.post.gaps.intimate <- final.Conn.intimate[19:nrow(final.Conn.intimate),]

NJ.pre.gaps.intimate <- final.NJ.intimate[1:13,]
NJ.post.gaps.intimate <- final.NJ.intimate[14:nrow(final.NJ.intimate),]

Delaware.pre.gaps.intimate <- final.Delaware.intimate[1:21,]
Delaware.post.gaps.intimate <- final.Delaware.intimate[22:nrow(final.Delaware.intimate),]

Maryland.pre.gaps.intimate <- final.maryland.intimate[1:19,]
Maryland.post.gaps.intimate <- final.maryland.intimate[20:nrow(final.maryland.intimate),]

diff.in.diff.ny.intimate <- colMeans(ny.post.gaps.intimate) - colMeans(ny.pre.gaps.intimate)
diff.in.diff.ny.placebo.intimate <- diff.in.diff.ny.intimate[1:(length(diff.in.diff.ny.intimate)-1)]
diff.in.diff.ny.actual.intimate <- diff.in.diff.ny.intimate[length(diff.in.diff.ny.intimate)]

diff.in.diff.nm.intimate <- colMeans(nm.post.gaps.intimate) - colMeans(nm.pre.gaps.intimate)
diff.in.diff.nm.placebo.intimate <- diff.in.diff.nm.intimate[1:(length(diff.in.diff.nm.intimate)-1)]
diff.in.diff.nm.actual.intimate <- diff.in.diff.nm.intimate[length(diff.in.diff.nm.intimate)]

diff.in.diff.Illinois.intimate <- colMeans(Illinois.post.gaps.intimate) - colMeans(Illinois.pre.gaps.intimate)
diff.in.diff.Illinois.placebo.intimate <- diff.in.diff.Illinois.intimate[1:(length(diff.in.diff.Illinois.intimate)-1)]
diff.in.diff.Illinois.actual.intimate <- diff.in.diff.Illinois.intimate[length(diff.in.diff.Illinois.intimate)]

diff.in.diff.Conn.intimate <- colMeans(Conn.post.gaps.intimate) - colMeans(Conn.pre.gaps.intimate)
diff.in.diff.Conn.placebo.intimate <- diff.in.diff.Conn.intimate[1:(length(diff.in.diff.Conn.intimate)-1)]
diff.in.diff.Conn.actual.intimate <- diff.in.diff.Conn.intimate[length(diff.in.diff.Conn.intimate)]

diff.in.diff.NJ.intimate <- colMeans(NJ.post.gaps.intimate) - colMeans(NJ.pre.gaps.intimate)
diff.in.diff.NJ.placebo.intimate <- diff.in.diff.NJ.intimate[1:(length(diff.in.diff.NJ.intimate)-1)]
diff.in.diff.NJ.actual.intimate <- diff.in.diff.NJ.intimate[length(diff.in.diff.NJ.intimate)]

diff.in.diff.Delaware.intimate <- colMeans(Delaware.post.gaps.intimate) - colMeans(Delaware.pre.gaps.intimate)
diff.in.diff.Delaware.placebo.intimate <- diff.in.diff.Delaware.intimate[1:(length(diff.in.diff.Delaware.intimate)-1)]
diff.in.diff.Delaware.actual.intimate <- diff.in.diff.Delaware.intimate[length(diff.in.diff.Delaware.intimate)]

diff.in.diff.Maryland.intimate <- colMeans(Maryland.post.gaps.intimate) - colMeans(Maryland.pre.gaps.intimate)
diff.in.diff.Maryland.placebo.intimate <- diff.in.diff.Maryland.intimate[1:(length(diff.in.diff.Maryland.intimate)-1)]
diff.in.diff.Maryland.actual.intimate <- diff.in.diff.Maryland.intimate[length(diff.in.diff.Maryland.intimate)]

exceeds.ny.intimate <- length(diff.in.diff.ny.placebo.intimate[diff.in.diff.ny.placebo.intimate>diff.in.diff.ny.actual.intimate])  
less.than.ny.intimate <- length(diff.in.diff.ny.placebo.intimate)-exceeds.ny.intimate

exceeds.nm.intimate <- length(diff.in.diff.nm.placebo.intimate[diff.in.diff.nm.placebo.intimate>diff.in.diff.nm.actual.intimate])  
less.than.nm.intimate <- length(diff.in.diff.nm.placebo.intimate)-exceeds.nm.intimate

exceeds.Illinois.intimate <- length(diff.in.diff.Illinois.placebo.intimate[diff.in.diff.Illinois.placebo.intimate>diff.in.diff.Illinois.actual.intimate])  
less.than.Illinois.intimate <- length(diff.in.diff.Illinois.placebo.intimate)-exceeds.Illinois.intimate

exceeds.Conn.intimate <- length(diff.in.diff.Conn.placebo.intimate[diff.in.diff.Conn.placebo.intimate>diff.in.diff.Conn.actual.intimate])  
less.than.Conn.intimate <- length(diff.in.diff.Conn.placebo.intimate)-exceeds.Conn.intimate

exceeds.NJ.intimate <- length(diff.in.diff.NJ.placebo.intimate[diff.in.diff.NJ.placebo.intimate>diff.in.diff.NJ.actual.intimate])  
less.than.NJ.intimate <- length(diff.in.diff.NJ.placebo.intimate)-exceeds.NJ.intimate

exceeds.Delaware.intimate <- length(diff.in.diff.Delaware.placebo.intimate[diff.in.diff.Delaware.placebo.intimate>diff.in.diff.Delaware.actual.intimate])  
less.than.Delaware.intimate <- length(diff.in.diff.Delaware.placebo.intimate)-exceeds.Delaware.intimate

exceeds.Maryland.intimate <- length(diff.in.diff.Maryland.placebo.intimate[diff.in.diff.Maryland.placebo.intimate>diff.in.diff.Maryland.actual.intimate])  
less.than.Maryland.intimate <- length(diff.in.diff.Maryland.placebo.intimate)-exceeds.Maryland.intimate

container.matrix.intimate <- matrix(nrow = 7, ncol = 5)
container.matrix.intimate[1,] <- c("New York", round(diff.in.diff.ny.actual.intimate, 2), exceeds.ny.intimate, less.than.ny.intimate, round((exceeds.ny.intimate/21), 2))
container.matrix.intimate[2,] <- c("New Mexico", round(diff.in.diff.nm.actual.intimate, 2), exceeds.nm.intimate, less.than.nm.intimate, round((exceeds.nm.intimate/21), 2))
container.matrix.intimate[3,] <- c("Illinois", round(diff.in.diff.Illinois.actual.intimate, 2), exceeds.Illinois.intimate, less.than.Illinois.intimate, round((exceeds.Illinois.intimate/21), 2))
container.matrix.intimate[4,] <- c("Connecticut", round(diff.in.diff.Conn.actual.intimate, 2), exceeds.Conn.intimate, less.than.Conn.intimate, round((exceeds.Conn.intimate/21), 2))
container.matrix.intimate[5,] <- c("New Jersey", round(diff.in.diff.NJ.actual.intimate, 2), exceeds.NJ.intimate, less.than.NJ.intimate, round((exceeds.NJ.intimate/21), 2))
container.matrix.intimate[6,] <- c("Delaware", round(diff.in.diff.Delaware.actual.intimate, 2), exceeds.Delaware.intimate, less.than.Delaware.intimate, round((exceeds.Delaware.intimate/21), 2))
container.matrix.intimate[7,] <- c("Maryland", round(diff.in.diff.Maryland.actual.intimate, 2), exceeds.Maryland.intimate, less.than.Maryland.intimate, round((exceeds.Maryland.intimate/21), 2))




```

```{r, include=F}

### New York 

new.york.effect.nl <- dataprep(foo = NY.Set, time.predictors.prior = c(1995:2004), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "ny.lag.1", "ny.lag.5", "ny.lag.9"), dependent = "Murder.Rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 36, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 

synth.out.nl <- synth(data.prep.obj = new.york.effect.nl, method = "All")

ny.tables.nl <- synth.tab(dataprep.res = new.york.effect.nl, synth.res = synth.out.nl)

path.plot(synth.res = synth.out.nl, dataprep.res = new.york.effect.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004)

ny.gaps.nl <- new.york.effect.nl$Y1plot - (new.york.effect.nl$Y0plot %*% synth.out.nl$solution.w)


### New Mexico

nm.effect.nl <- dataprep(foo = NM.Set, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nm.lag.1", "nm.lag.7", "nm.lag.14"), dependent = "Murder.Rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 40, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 

synth.out.2.nl <- synth(data.prep.obj = nm.effect.nl, method = "All")

nm.tables.nl <- synth.tab(dataprep.res = nm.effect.nl, synth.res = synth.out.2.nl)


path.plot(synth.res = synth.out.2.nl, dataprep.res = nm.effect.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009)

nm.gaps.nl <- nm.effect.nl$Y1plot - (nm.effect.nl$Y0plot %*% synth.out.2.nl$solution.w)


### Illinois 

Illinois.effect.nl <- dataprep(foo = Illinois.Set, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "illinois.lag.1", "illinois.lag.8", "illinois.lag.16"), dependent = "Murder.Rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 39, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 

synth.out.3.nl <- synth(data.prep.obj = Illinois.effect.nl, method = "All")

Illinois.tables.nl <- synth.tab(dataprep.res = Illinois.effect.nl, synth.res = synth.out.3.nl)

path.plot(synth.res = synth.out.3.nl, dataprep.res = Illinois.effect.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011)

Illinois.gaps.nl <- Illinois.effect.nl$Y1plot - (Illinois.effect.nl$Y0plot %*% synth.out.3.nl$solution.w)


### Connecticut

Conn.effect.nl <- dataprep(foo = Conn.Set, time.predictors.prior = c(1995:2012), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "conn.lag.1", "conn.lag.9", "conn.lag.17"), dependent = "Murder.Rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 41, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 

synth.out.4.nl <- synth(data.prep.obj = Conn.effect.nl, method = "All")

Conn.tables.nl <- synth.tab(dataprep.res = Conn.effect.nl, synth.res = synth.out.4.nl)

path.plot(synth.res = synth.out.4.nl, dataprep.res = Conn.effect.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012)

Conn.gaps.nl <- Conn.effect.nl$Y1plot - (Conn.effect.nl$Y0plot %*% synth.out.4.nl$solution.w)


### New Jersey

NJ.effect.nl <- dataprep(foo = NJ.Set, time.predictors.prior = c(1995:2007), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nj.lag.1", "nj.lag.6", "nj.lag.12"), dependent = "Murder.Rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 42, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 

synth.out.5.nl <- synth(data.prep.obj = NJ.effect.nl, method = "All")

NJ.tables.nl <- synth.tab(dataprep.res = NJ.effect.nl, synth.res = synth.out.5.nl)

path.plot(synth.res = synth.out.5.nl, dataprep.res = NJ.effect.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007)

NJ.gaps.nl <- NJ.effect.nl$Y1plot - (NJ.effect.nl$Y0plot %*% synth.out.5.nl$solution.w)

### Delaware

Delaware.effect.nl <- dataprep(foo = Delaware.Set, time.predictors.prior = c(1995:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "del.lag.1", "del.lag.11", "del.lag.21"), dependent = "Murder.Rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 38, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2016), time.plot = c(1995:2018)) 

synth.out.6.nl <- synth(data.prep.obj = Delaware.effect.nl, method = "All")

Delaware.tables.nl <- synth.tab(dataprep.res = Delaware.effect.nl, synth.res = synth.out.6.nl)


path.plot(synth.res = synth.out.6.nl, dataprep.res = Delaware.effect.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016)

Delaware.gaps.nl <- Delaware.effect.nl$Y1plot - (Delaware.effect.nl$Y0plot %*% synth.out.6.nl$solution.w)

### Maryland

Maryland.effect.nl <- dataprep(foo = Maryland.Set, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "maryland.lag.1", "maryland.lag.9", "maryland.lag.18"), dependent = "Murder.Rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 37, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 

synth.out.7.nl <- synth(data.prep.obj = Maryland.effect.nl, method = "All")

path.plot(synth.res = synth.out.7.nl, dataprep.res = Maryland.effect.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013)

Maryland.tables.nl <- synth.tab(dataprep.res = Maryland.effect.nl, synth.res = synth.out.7.nl)

Maryland.gaps.nl <- Maryland.effect.nl$Y1plot - (Maryland.effect.nl$Y0plot %*% synth.out.7.nl$solution.w)



############### ############### ############### 
############### Single Plot ###############
############### ############### ############### 



### New York 

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))
path.plot(synth.res = synth.out.nl, dataprep.res = new.york.effect.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,15))
abline(v=2004, col = "red")

### New Mexico


path.plot(synth.res = synth.out.2.nl, dataprep.res = nm.effect.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,15))
abline(v=2009, col = "red")
mtext("Figure X: Synthetic Control Plots for States That Eliminated Capital Punishment (y = Murders Per 100,000 Residents)", side = 3, line = 4, font = 2)

### Illinois 


path.plot(synth.res = synth.out.3.nl, dataprep.res = Illinois.effect.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,15))
abline(v=2011, col = "red")



### Connecticut


path.plot(synth.res = synth.out.4.nl, dataprep.res = Conn.effect.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,15))
abline(v=2012, col = "red")


### New Jersey


path.plot(synth.res = synth.out.5.nl, dataprep.res = NJ.effect.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,15))
abline(v=2007, col = "red")


### Delaware


path.plot(synth.res = synth.out.6.nl, dataprep.res = Delaware.effect.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,15))
abline(v=2016, col = "red")


### Maryland

path.plot(synth.res = synth.out.7.nl, dataprep.res = Maryland.effect.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,15))
abline(v=2013, col = "red")

legend.cols <- c("black", "black", "red")
names(legend.cols) <- c("Treated", "Synthetic Control", "Year Eliminated DP")
par(fig= c(0, 1, 0, 1), oma = c(0,0,0,0), mar = c(.5, .5, .5, .5), new=TRUE)
plot(0,0, type = "n", bty="n", xaxt ="n", yaxt="n")
legend("bottom", text.width=c(0.3,0.3,0.3), legend=names(legend.cols), col = legend.cols, lty = c(1,2,1), lwd = c(2.5, 2.5, 2.5), cex = .75, xpd = TRUE, horiz = F, inset = c(0,0,0), bty = "y", text.font = 2)


########################################
###### Adding to Placebo Gap Analysis ############
########################################

#### NY Placebo Prep
ny.placebos.nl <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.ny.nl <- dataprep(foo = death.set, time.predictors.prior = c(1995:2004), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "ny.lag.1", "ny.lag.5", "ny.lag.9"), dependent = "Murder.Rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 
  synth.out.9.nl <- synth(data.prep.obj = death.set.effect.ny.nl, method = "All")
  death.set.effect.ny.gaps.nl <- death.set.effect.ny.nl$Y1plot - (death.set.effect.ny.nl$Y0plot %*% synth.out.9.nl$solution.w);
  ny.placebos.nl[,i] <- death.set.effect.ny.gaps.nl
  i <- i + 1
}

final.ny.nl <- cbind(ny.placebos.nl, ny.gaps.nl)
years <- seq(from=1995, to = 2018, by=1)

#### NM Placebo Prep
NM.placebos.nl <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NM.nl <- dataprep(foo = death.set, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nm.lag.1", "nm.lag.7", "nm.lag.14"), dependent = "Murder.Rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 
  synth.out.10.nl <- synth(data.prep.obj = death.set.effect.NM.nl, method = "All")
  death.set.effect.nm.gaps.nl <- death.set.effect.NM.nl$Y1plot - (death.set.effect.NM.nl$Y0plot %*% synth.out.10.nl$solution.w);
  NM.placebos.nl[,i] <- death.set.effect.nm.gaps.nl
  i <- i + 1
}

final.NM.nl <- cbind(NM.placebos.nl, nm.gaps.nl)
years <- seq(from=1995, to = 2018, by=1)


#### Illinois Placebo Prep
Illinois.placebos.nl <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Illinois.nl <- dataprep(foo = death.set, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "illinois.lag.1", "illinois.lag.8", "illinois.lag.16"), dependent = "Murder.Rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 
  synth.out.11.nl <- synth(data.prep.obj = death.set.effect.Illinois.nl, method = "All")
  death.set.effect.Illinois.gaps.nl <- death.set.effect.Illinois.nl$Y1plot - (death.set.effect.Illinois.nl$Y0plot %*% synth.out.11.nl$solution.w);
  Illinois.placebos.nl[,i] <- death.set.effect.Illinois.gaps.nl
  i <- i + 1
}

final.Illinois.nl <- cbind(Illinois.placebos.nl, Illinois.gaps.nl)
years <- seq(from=1995, to = 2018, by=1)


#### Conn Placebo Prep
Conn.placebos.nl <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Conn.nl <- dataprep(foo = death.set, time.predictors.prior = c(1995:2012), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "conn.lag.1", "conn.lag.9", "conn.lag.17"), dependent = "Murder.Rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 
  synth.out.12.nl <- synth(data.prep.obj = death.set.effect.Conn.nl, method = "All")
  death.set.effect.Conn.gaps.nl <- death.set.effect.Conn.nl$Y1plot - (death.set.effect.Conn.nl$Y0plot %*% synth.out.12.nl$solution.w);
  Conn.placebos.nl[,i] <- death.set.effect.Conn.gaps.nl
  i <- i + 1
}

final.Conn.nl <- cbind(Conn.placebos.nl, Conn.gaps.nl)
years <- seq(from=1995, to = 2018, by=1)


#### NJ Placebo Prep
NJ.placebos.nl <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NJ.nl <- dataprep(foo = death.set, time.predictors.prior = c(1995:2007), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nj.lag.1", "nj.lag.6", "nj.lag.12"), dependent = "Murder.Rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 
  synth.out.13.nl <- synth(data.prep.obj = death.set.effect.NJ.nl, method = "All")
  death.set.effect.NJ.gaps.nl <- death.set.effect.NJ.nl$Y1plot - (death.set.effect.NJ.nl$Y0plot %*% synth.out.13.nl$solution.w);
  NJ.placebos.nl[,i] <- death.set.effect.NJ.gaps.nl
  i <- i + 1
}

final.NJ.nl <- cbind(NJ.placebos.nl, NJ.gaps.nl)
years <- seq(from=1995, to = 2018, by=1)


#### Delaware Placebo Prep
Delaware.placebos.nl <- matrix(nrow = 24, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Delaware.nl <- dataprep(foo = death.set, time.predictors.prior = c(1995:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "del.lag.1", "del.lag.11", "del.lag.21"), dependent = "Murder.Rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2016), time.plot = c(1995:2018)) 
  synth.out.14.nl <- synth(data.prep.obj = death.set.effect.Delaware.nl, method = "All")
  death.set.effect.Delaware.gaps.nl <- death.set.effect.Delaware.nl$Y1plot - (death.set.effect.Delaware.nl$Y0plot %*% synth.out.14.nl$solution.w);
  Delaware.placebos.nl[,i] <- death.set.effect.Delaware.gaps.nl
  i <- i + 1
}

final.Delaware.nl <- cbind(Delaware.placebos.nl, Delaware.gaps.nl)
years <- seq(from=1995, to = 2018, by=1)

#### Maryland Placebo Prep


maryland.placebos.nl <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
controls <- c(1:29)
controls.complete <- controls[controls!=s]
death.set.effect.maryland.nl <- dataprep(foo = death.set, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "maryland.lag.1", "maryland.lag.9", "maryland.lag.18"), dependent = "Murder.Rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 
synth.out.8.nl <- synth(data.prep.obj = death.set.effect.maryland.nl, method = "All")
death.set.maryland.gaps.nl <- death.set.effect.maryland.nl$Y1plot - (death.set.effect.maryland.nl$Y0plot %*% synth.out.8.nl$solution.w);
maryland.placebos.nl[,i] <- death.set.maryland.gaps.nl
i <- i + 1
}

maryland.placebos.nl
final.maryland.nl <- cbind(maryland.placebos.nl, Maryland.gaps.nl)
years <- seq(from=1995, to = 2018, by=1)



########################################
########## Permutation Calculations ##########
########################################

ny.pre.gaps.nl <- final.ny.nl[1:10,]
ny.post.gaps.nl <- final.ny.nl[11:nrow(final.ny.nl),]

nm.pre.gaps.nl <- final.NM.nl[1:15,]
nm.post.gaps.nl <- final.NM.nl[16:nrow(final.NM.nl),]

Illinois.pre.gaps.nl <- final.Illinois.nl[1:17,]
Illinois.post.gaps.nl <- final.Illinois.nl[18:nrow(final.Illinois.nl),]

Conn.pre.gaps.nl <- final.Conn.nl[1:18,]
Conn.post.gaps.nl <- final.Conn.nl[19:nrow(final.Conn.nl),]

NJ.pre.gaps.nl <- final.NJ.nl[1:13,]
NJ.post.gaps.nl <- final.NJ.nl[14:nrow(final.NJ.nl),]

Delaware.pre.gaps.nl <- final.Delaware.nl[1:22,]
Delaware.post.gaps.nl <- final.Delaware.nl[23:nrow(final.Delaware.nl),]

Maryland.pre.gaps.nl <- final.maryland.nl[1:19,]
Maryland.post.gaps.nl <- final.maryland.nl[20:nrow(final.maryland.nl),]

diff.in.diff.ny.nl <- colMeans(ny.post.gaps.nl) - colMeans(ny.pre.gaps.nl)
diff.in.diff.ny.placebo.nl <- diff.in.diff.ny.nl[1:(length(diff.in.diff.ny.nl)-1)]
diff.in.diff.ny.actual.nl <- diff.in.diff.ny.nl[length(diff.in.diff.ny.nl)]

diff.in.diff.nm.nl <- colMeans(nm.post.gaps.nl) - colMeans(nm.pre.gaps.nl)
diff.in.diff.nm.placebo.nl <- diff.in.diff.nm.nl[1:(length(diff.in.diff.nm.nl)-1)]
diff.in.diff.nm.actual.nl <- diff.in.diff.nm.nl[length(diff.in.diff.nm.nl)]

diff.in.diff.Illinois.nl <- colMeans(Illinois.post.gaps.nl) - colMeans(Illinois.pre.gaps.nl)
diff.in.diff.Illinois.placebo.nl <- diff.in.diff.Illinois.nl[1:(length(diff.in.diff.Illinois.nl)-1)]
diff.in.diff.Illinois.actual.nl <- diff.in.diff.Illinois.nl[length(diff.in.diff.Illinois.nl)]

diff.in.diff.Conn.nl <- colMeans(Conn.post.gaps.nl) - colMeans(Conn.pre.gaps.nl)
diff.in.diff.Conn.placebo.nl <- diff.in.diff.Conn.nl[1:(length(diff.in.diff.Conn.nl)-1)]
diff.in.diff.Conn.actual.nl <- diff.in.diff.Conn.nl[length(diff.in.diff.Conn.nl)]

diff.in.diff.NJ.nl <- colMeans(NJ.post.gaps.nl) - colMeans(NJ.pre.gaps.nl)
diff.in.diff.NJ.placebo.nl <- diff.in.diff.NJ.nl[1:(length(diff.in.diff.NJ.nl)-1)]
diff.in.diff.NJ.actual.nl <- diff.in.diff.NJ.nl[length(diff.in.diff.NJ.nl)]

diff.in.diff.Delaware.nl <- colMeans(Delaware.post.gaps.nl) - colMeans(Delaware.pre.gaps.nl)
diff.in.diff.Delaware.placebo.nl <- diff.in.diff.Delaware.nl[1:(length(diff.in.diff.Delaware.nl)-1)]
diff.in.diff.Delaware.actual.nl <- diff.in.diff.Delaware.nl[length(diff.in.diff.Delaware.nl)]

diff.in.diff.Maryland.nl <- colMeans(Maryland.post.gaps.nl) - colMeans(Maryland.pre.gaps.nl)
diff.in.diff.Maryland.placebo.nl <- diff.in.diff.Maryland.nl[1:(length(diff.in.diff.Maryland.nl)-1)]
diff.in.diff.Maryland.actual.nl <- diff.in.diff.Maryland.nl[length(diff.in.diff.Maryland.nl)]
  
exceeds.ny.nl <- length(diff.in.diff.ny.placebo.nl[diff.in.diff.ny.placebo.nl>diff.in.diff.ny.actual.nl])  
less.than.ny.nl <- length(diff.in.diff.ny.placebo.nl)-exceeds.ny.nl

exceeds.nm.nl <- length(diff.in.diff.nm.placebo.nl[diff.in.diff.nm.placebo.nl>diff.in.diff.nm.actual.nl])  
less.than.nm.nl <- length(diff.in.diff.nm.placebo.nl)-exceeds.nm.nl

exceeds.Illinois.nl <- length(diff.in.diff.Illinois.placebo.nl[diff.in.diff.Illinois.placebo.nl>diff.in.diff.Illinois.actual.nl])  
less.than.Illinois.nl <- length(diff.in.diff.Illinois.placebo.nl)-exceeds.Illinois.nl

exceeds.Conn.nl <- length(diff.in.diff.Conn.placebo.nl[diff.in.diff.Conn.placebo.nl>diff.in.diff.Conn.actual.nl])  
less.than.Conn.nl <- length(diff.in.diff.Conn.placebo.nl)-exceeds.Conn.nl

exceeds.NJ.nl <- length(diff.in.diff.NJ.placebo.nl[diff.in.diff.NJ.placebo.nl>diff.in.diff.NJ.actual.nl])  
less.than.NJ.nl <- length(diff.in.diff.NJ.placebo.nl)-exceeds.NJ.nl

exceeds.Delaware.nl <- length(diff.in.diff.Delaware.placebo.nl[diff.in.diff.Delaware.placebo.nl>diff.in.diff.Delaware.actual.nl])  
less.than.Delaware.nl <- length(diff.in.diff.Delaware.placebo.nl)-exceeds.Delaware.nl

exceeds.Maryland.nl <- length(diff.in.diff.Maryland.placebo.nl[diff.in.diff.Maryland.placebo.nl>diff.in.diff.Maryland.actual.nl])  
less.than.Maryland.nl <- length(diff.in.diff.Maryland.placebo.nl)-exceeds.Maryland.nl

container.matrix.nl <- matrix(nrow = 7, ncol = 5)
container.matrix.nl[1,] <- c("New York", round(diff.in.diff.ny.actual.nl, 2), exceeds.ny.nl, less.than.ny.nl, round((exceeds.ny.nl/29), 2))
container.matrix.nl[2,] <- c("New Mexico", round(diff.in.diff.nm.actual.nl, 2), exceeds.nm.nl, less.than.nm.nl, round((exceeds.nm.nl/29), 2))
container.matrix.nl[3,] <- c("Illinois", round(diff.in.diff.Illinois.actual.nl, 2), exceeds.Illinois.nl, less.than.Illinois.nl, round((exceeds.Illinois.nl/29), 2))
container.matrix.nl[4,] <- c("Connecticut", round(diff.in.diff.Conn.actual.nl, 2), exceeds.Conn.nl, less.than.Conn.nl, round((exceeds.Conn.nl/29), 2))
container.matrix.nl[5,] <- c("New Jersey", round(diff.in.diff.NJ.actual.nl, 2), exceeds.NJ.nl, less.than.NJ.nl, round((exceeds.NJ.nl/29), 2))
container.matrix.nl[6,] <- c("Delaware", round(diff.in.diff.Delaware.actual.nl, 2), exceeds.Delaware.nl, less.than.Delaware.nl, round((exceeds.Delaware.nl/29), 2))
container.matrix.nl[7,] <- c("Maryland", round(diff.in.diff.Maryland.actual.nl, 2), exceeds.Maryland.nl, less.than.Maryland.nl, round((exceeds.Maryland.nl/29), 2))

sum.stats.nl <- as.data.frame(container.matrix.nl)


NY.Set.nb <- NY.Set[NY.Set$State!="Pennsylvania",]

### New York 

new.york.effect.nb <- dataprep(foo = NY.Set.nb, time.predictors.prior = c(1995:2004), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "ny.lag.1", "ny.lag.5", "ny.lag.9"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 36, controls.identifier = c(1:21, 23:29), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 

synth.out.nb <- synth(data.prep.obj = new.york.effect.nb, method = "All")

ny.tables.nb <- synth.tab(dataprep.res = new.york.effect.nb, synth.res = synth.out.nb)

path.plot(synth.res = synth.out.nb, dataprep.res = new.york.effect.nb, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004)

ny.gaps.nb <- new.york.effect.nb$Y1plot - (new.york.effect.nb$Y0plot %*% synth.out.nb$solution.w)


### New Mexico

NM.Set.nb <- NM.Set[(NM.Set$State!="Texas" & NM.Set$State!="Oklahoma" & NM.Set$State!="Colorado" & NM.Set$State!="Utah" & NM.Set$State!="Arizona"),]

nm.effect.nb <- dataprep(foo = NM.Set.nb, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nm.lag.1", "nm.lag.7", "nm.lag.14"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 40, controls.identifier = c(1,3,4,6:19,21:25, 28, 29), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 

synth.out.2.nb <- synth(data.prep.obj = nm.effect.nb, method = "All")

nm.tables.nb <- synth.tab(dataprep.res = nm.effect.nb, synth.res = synth.out.2.nb)


path.plot(synth.res = synth.out.2.nb, dataprep.res = nm.effect.nb, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009)

nm.gaps.nb <- nm.effect.nb$Y1plot - (nm.effect.nb$Y0plot %*% synth.out.2.nb$solution.w)


### Illinois 

Illinois.Set.nb <- Illinois.Set[(Illinois.Set$State!="Indiana" & Illinois.Set$State!="Kentucky" & Illinois.Set$State!="Missouri"),]

Illinois.effect.nb <- dataprep(foo = Illinois.Set.nb, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "illinois.lag.1", "illinois.lag.8", "illinois.lag.16"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 39, controls.identifier = c(1:8,10,12,13,15:29), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 

synth.out.3.nb <- synth(data.prep.obj = Illinois.effect.nb, method = "All")

Illinois.tables.nb <- synth.tab(dataprep.res = Illinois.effect.nb, synth.res = synth.out.3.nb)

path.plot(synth.res = synth.out.3.nb, dataprep.res = Illinois.effect.nb, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011)

Illinois.gaps.nb <- Illinois.effect.nb$Y1plot - (Illinois.effect.nb$Y0plot %*% synth.out.3.nb$solution.w)


### Connecticut

Conn.effect <- dataprep(foo = Conn.Set, time.predictors.prior = c(1995:2012), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "conn.lag.1", "conn.lag.9", "conn.lag.17"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 41, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 

synth.out.4 <- synth(data.prep.obj = Conn.effect, method = "All")

Conn.tables <- synth.tab(dataprep.res = Conn.effect, synth.res = synth.out.4)

path.plot(synth.res = synth.out.4, dataprep.res = Conn.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012)

Conn.gaps <- Conn.effect$Y1plot - (Conn.effect$Y0plot %*% synth.out.4$solution.w)


### New Jersey

NJ.Set.nb <- NJ.Set[(NJ.Set$State!="Pennsylvania"),]


NJ.effect.nb <- dataprep(foo = NJ.Set.nb, time.predictors.prior = c(1995:2007), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nj.lag.1", "nj.lag.6", "nj.lag.12"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 42, controls.identifier = c(1:21, 23:29), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 

synth.out.5.nb <- synth(data.prep.obj = NJ.effect.nb, method = "All")

NJ.tables.nb <- synth.tab(dataprep.res = NJ.effect.nb, synth.res = synth.out.5.nb)

path.plot(synth.res = synth.out.5.nb, dataprep.res = NJ.effect.nb, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007)

NJ.gaps.nb <- NJ.effect.nb$Y1plot - (NJ.effect.nb$Y0plot %*% synth.out.5.nb$solution.w)

### Delaware

Delaware.Set.nb <- Delaware.Set[(Delaware.Set$State!="Pennsylvania"),]

Delaware.effect.nb <- dataprep(foo = Delaware.Set.nb, time.predictors.prior = c(1995:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "del.lag.1", "del.lag.11", "del.lag.21"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 38, controls.identifier = c(1:21, 23:29), time.optimize.ssr = c(1995:2016), time.plot = c(1995:2018)) 

synth.out.6.nb <- synth(data.prep.obj = Delaware.effect.nb, method = "All")

Delaware.tables.nb <- synth.tab(dataprep.res = Delaware.effect.nb, synth.res = synth.out.6.nb)


path.plot(synth.res = synth.out.6.nb, dataprep.res = Delaware.effect.nb, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016)

Delaware.gaps.nb <- Delaware.effect.nb$Y1plot - (Delaware.effect.nb$Y0plot %*% synth.out.6.nb$solution.w)

### Maryland

Maryland.Set.nb <- Maryland.Set[(Maryland.Set$State!="Pennsylvania" & Maryland.Set$State!="Virginia"),]


Maryland.effect.nb <- dataprep(foo = Maryland.Set.nb, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "maryland.lag.1", "maryland.lag.9", "maryland.lag.18"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 37, controls.identifier = c(1:21,23:27, 29), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 

synth.out.7.nb <- synth(data.prep.obj = Maryland.effect.nb, method = "All")

path.plot(synth.res = synth.out.7.nb, dataprep.res = Maryland.effect.nb, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013)

Maryland.tables.nb <- synth.tab(dataprep.res = Maryland.effect.nb, synth.res = synth.out.7.nb)

Maryland.gaps.nb <- Maryland.effect.nb$Y1plot - (Maryland.effect.nb$Y0plot %*% synth.out.7.nb$solution.w)



############### ############### ############### 
############### Single Plot ###############
############### ############### ############### 



### New York 

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))
path.plot(synth.res = synth.out.nb, dataprep.res = new.york.effect.nb, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004, col = "red")

### New Mexico


path.plot(synth.res = synth.out.2.nb, dataprep.res = nm.effect.nb, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009, col = "red")
mtext("Figure X: Strengthening No Spillover Assumption By Removing Bordering States (y = Log Murders Per 100,000 Residents)", side = 3, line = 4, font = 2)

### Illinois 


path.plot(synth.res = synth.out.3.nb, dataprep.res = Illinois.effect.nb, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011, col = "red")



### Connecticut


path.plot(synth.res = synth.out.4, dataprep.res = Conn.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012, col = "red")


### New Jersey


path.plot(synth.res = synth.out.5.nb, dataprep.res = NJ.effect.nb, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007, col = "red")


### Delaware


path.plot(synth.res = synth.out.6.nb, dataprep.res = Delaware.effect.nb, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016, col = "red")


### Maryland

path.plot(synth.res = synth.out.7.nb, dataprep.res = Maryland.effect.nb, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013, col = "red")

legend.cols <- c("black", "black", "red")
names(legend.cols) <- c("Treated", "Synthetic Control", "Year Eliminated DP")
par(fig= c(0, 1, 0, 1), oma = c(0,0,0,0), mar = c(.5, .5, .5, .5), new=TRUE)
plot(0,0, type = "n", bty="n", xaxt ="n", yaxt="n")
legend("bottom", text.width=c(0.3,0.3,0.3), legend=names(legend.cols), col = legend.cols, lty = c(1,2,1), lwd = c(2.5, 2.5, 2.5), cex = .75, xpd = TRUE, horiz = F, inset = c(0,0,0), bty = "y", text.font = 2)




death.set.nb.1 <- death.set[death.set$State!="Pennsylvania",]

ny.placebos.nb <- matrix(nrow = 21, ncol = 28)
i <- 1
for (s in c(1:21, 23:29)) {
  controls <- c(1:21, 23:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.ny <- dataprep(foo = death.set.nb.1, time.predictors.prior = c(1995:2004), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "ny.lag.1", "ny.lag.5", "ny.lag.9"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 
  synth.out.9 <- synth(data.prep.obj = death.set.effect.ny, method = "All")
  death.set.effect.ny.gaps <- death.set.effect.ny$Y1plot - (death.set.effect.ny$Y0plot %*% synth.out.9$solution.w);
  ny.placebos.nb[,i] <- death.set.effect.ny.gaps
  i <- i + 1
}

final.ny.nb <- cbind(ny.placebos.nb, ny.gaps.nb)
years <- seq(from=1995, to = 2018, by=1)

#### NM Placebo Prep

death.set.nb.2 <- death.set[(death.set$State!="Texas" & death.set$State!="Oklahoma" & death.set$State!="Colorado" & death.set$State!="Utah" & death.set$State!="Arizona"),]

NM.placebos.nb <- matrix(nrow = 21, ncol = 24)
i <- 1
for (s in c(1,3,4,6:19,21:25, 28, 29)) {
  controls <- c(1,3,4,6:19,21:25, 28, 29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NM <- dataprep(foo = death.set.nb.2, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nm.lag.1", "nm.lag.7", "nm.lag.14"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 
  synth.out.10 <- synth(data.prep.obj = death.set.effect.NM, method = "All")
  death.set.effect.nm.gaps <- death.set.effect.NM$Y1plot - (death.set.effect.NM$Y0plot %*% synth.out.10$solution.w);
  NM.placebos.nb[,i] <- death.set.effect.nm.gaps
  i <- i + 1
}

final.NM.nb <- cbind(NM.placebos.nb, nm.gaps.nb)
years <- seq(from=1995, to = 2018, by=1)


#### Illinois Placebo Prep

death.set.nb.3 <- death.set[(death.set$State!="Indiana" & death.set$State!="Kentucky" & death.set$State!="Missouri"),]

Illinois.placebos.nb <- matrix(nrow = 23, ncol = 26)
i <- 1
for (s in c(1:8,10,12,13,15:29)) {
  controls <- c(1:8,10,12,13,15:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Illinois <- dataprep(foo = death.set.nb.3, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "illinois.lag.1", "illinois.lag.8", "illinois.lag.16"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 
  synth.out.11 <- synth(data.prep.obj = death.set.effect.Illinois, method = "All")
  death.set.effect.Illinois.gaps <- death.set.effect.Illinois$Y1plot - (death.set.effect.Illinois$Y0plot %*% synth.out.11$solution.w);
  Illinois.placebos.nb[,i] <- death.set.effect.Illinois.gaps
  i <- i + 1
}

final.Illinois.nb <- cbind(Illinois.placebos.nb, Illinois.gaps.nb)
years <- seq(from=1995, to = 2018, by=1)


#### Conn Placebo Prep
Conn.placebos <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Conn <- dataprep(foo = death.set, time.predictors.prior = c(1995:2012), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "conn.lag.1", "conn.lag.9", "conn.lag.17"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 
  synth.out.12 <- synth(data.prep.obj = death.set.effect.Conn, method = "All")
  death.set.effect.Conn.gaps <- death.set.effect.Conn$Y1plot - (death.set.effect.Conn$Y0plot %*% synth.out.12$solution.w);
  Conn.placebos[,i] <- death.set.effect.Conn.gaps
  i <- i + 1
}

final.Conn <- cbind(Conn.placebos, Conn.gaps)
years <- seq(from=1995, to = 2018, by=1)


#### NJ Placebo Prep

death.set.nb.5 <- death.set[(death.set$State!="Pennsylvania"),]

NJ.placebos.nb <- matrix(nrow = 21, ncol = 28)
i <- 1
for (s in c(1:21, 23:29)) {
  controls <- c(1:21, 23:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NJ <- dataprep(foo = death.set.nb.5, time.predictors.prior = c(1995:2007), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc", "nj.lag.1", "nj.lag.6", "nj.lag.12"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 
  synth.out.13 <- synth(data.prep.obj = death.set.effect.NJ, method = "All")
  death.set.effect.NJ.gaps <- death.set.effect.NJ$Y1plot - (death.set.effect.NJ$Y0plot %*% synth.out.13$solution.w);
  NJ.placebos.nb[,i] <- death.set.effect.NJ.gaps
  i <- i + 1
}

final.NJ.nb <- cbind(NJ.placebos.nb, NJ.gaps.nb)
years <- seq(from=1995, to = 2018, by=1)


#### Delaware Placebo Prep

death.set.nb.6 <- death.set[(death.set$State!="Pennsylvania"),]

Delaware.placebos.nb <- matrix(nrow = 24, ncol = 28)
i <- 1
for (s in c(1:21, 23:29)) {
  controls <- c(1:21, 23:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Delaware <- dataprep(foo = death.set.nb.6, time.predictors.prior = c(1995:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "del.lag.1", "del.lag.11", "del.lag.21"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2016), time.plot = c(1995:2018)) 
  synth.out.14 <- synth(data.prep.obj = death.set.effect.Delaware, method = "All")
  death.set.effect.Delaware.gaps <- death.set.effect.Delaware$Y1plot - (death.set.effect.Delaware$Y0plot %*% synth.out.14$solution.w);
  Delaware.placebos.nb[,i] <- death.set.effect.Delaware.gaps
  i <- i + 1
}

final.Delaware.nb <- cbind(Delaware.placebos.nb, Delaware.gaps.nb)
years <- seq(from=1995, to = 2018, by=1)

#### Maryland Placebo Prep

death.set.nb.7 <- death.set[(death.set$State!="Pennsylvania" & death.set$State!="Virginia"),]

maryland.placebos.nb <- matrix(nrow = 23, ncol = 27)
i <- 1
for (s in c(1:21,23:27, 29)) {
  controls <- c(1:21,23:27, 29)
  controls.complete <- controls[controls!=s]
  death.set.effect.maryland <- dataprep(foo = death.set.nb.7, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "maryland.lag.1", "maryland.lag.9", "maryland.lag.18"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 
  synth.out.8 <- synth(data.prep.obj = death.set.effect.maryland, method = "All")
  death.set.maryland.gaps <- death.set.effect.maryland$Y1plot - (death.set.effect.maryland$Y0plot %*% synth.out.8$solution.w);
  maryland.placebos.nb[,i] <- death.set.maryland.gaps
  i <- i + 1
}


final.maryland.nb <- cbind(maryland.placebos.nb, Maryland.gaps.nb)
years <- seq(from=1995, to = 2018, by=1)



########################################
########## Permutation Calculations ##########
########################################

ny.pre.gaps.nb <- final.ny.nb[1:10,]
ny.post.gaps.nb <- final.ny.nb[11:nrow(final.ny.nb),]

nm.pre.gaps.nb <- final.NM.nb[1:15,]
nm.post.gaps.nb <- final.NM.nb[16:nrow(final.NM.nb),]

Illinois.pre.gaps.nb <- final.Illinois.nb[1:17,]
Illinois.post.gaps.nb <- final.Illinois.nb[18:nrow(final.Illinois.nb),]

Conn.pre.gaps <- final.Conn[1:18,]
Conn.post.gaps <- final.Conn[19:nrow(final.Conn),]

NJ.pre.gaps.nb <- final.NJ.nb[1:13,]
NJ.post.gaps.nb <- final.NJ.nb[14:nrow(final.NJ.nb),]

Delaware.pre.gaps.nb <- final.Delaware.nb[1:22,]
Delaware.post.gaps.nb <- final.Delaware.nb[23:nrow(final.Delaware.nb),]

Maryland.pre.gaps.nb <- final.maryland.nb[1:19,]
Maryland.post.gaps.nb <- final.maryland.nb[20:nrow(final.maryland.nb),]

diff.in.diff.ny.nb <- colMeans(ny.post.gaps.nb) - colMeans(ny.pre.gaps.nb)
diff.in.diff.ny.placebo.nb <- diff.in.diff.ny.nb[1:(length(diff.in.diff.ny.nb)-1)]
diff.in.diff.ny.actual.nb <- diff.in.diff.ny.nb[length(diff.in.diff.ny.nb)]

diff.in.diff.nm.nb <- colMeans(nm.post.gaps.nb) - colMeans(nm.pre.gaps.nb)
diff.in.diff.nm.placebo.nb <- diff.in.diff.nm.nb[1:(length(diff.in.diff.nm.nb)-1)]
diff.in.diff.nm.actual.nb <- diff.in.diff.nm.nb[length(diff.in.diff.nm.nb)]

diff.in.diff.Illinois.nb <- colMeans(Illinois.post.gaps.nb) - colMeans(Illinois.pre.gaps.nb)
diff.in.diff.Illinois.placebo.nb <- diff.in.diff.Illinois.nb[1:(length(diff.in.diff.Illinois.nb)-1)]
diff.in.diff.Illinois.actual.nb <- diff.in.diff.Illinois.nb[length(diff.in.diff.Illinois.nb)]

diff.in.diff.Conn <- colMeans(Conn.post.gaps) - colMeans(Conn.pre.gaps)
diff.in.diff.Conn.placebo <- diff.in.diff.Conn[1:(length(diff.in.diff.Conn)-1)]
diff.in.diff.Conn.actual <- diff.in.diff.Conn[length(diff.in.diff.Conn)]

diff.in.diff.NJ.nb <- colMeans(NJ.post.gaps.nb) - colMeans(NJ.pre.gaps.nb)
diff.in.diff.NJ.placebo.nb <- diff.in.diff.NJ.nb[1:(length(diff.in.diff.NJ.nb)-1)]
diff.in.diff.NJ.actual.nb <- diff.in.diff.NJ.nb[length(diff.in.diff.NJ.nb)]

diff.in.diff.Delaware.nb <- colMeans(Delaware.post.gaps.nb) - colMeans(Delaware.pre.gaps.nb)
diff.in.diff.Delaware.placebo.nb <- diff.in.diff.Delaware.nb[1:(length(diff.in.diff.Delaware.nb)-1)]
diff.in.diff.Delaware.actual.nb <- diff.in.diff.Delaware.nb[length(diff.in.diff.Delaware.nb)]

diff.in.diff.Maryland.nb <- colMeans(Maryland.post.gaps.nb) - colMeans(Maryland.pre.gaps.nb)
diff.in.diff.Maryland.placebo.nb <- diff.in.diff.Maryland.nb[1:(length(diff.in.diff.Maryland.nb)-1)]
diff.in.diff.Maryland.actual.nb <- diff.in.diff.Maryland.nb[length(diff.in.diff.Maryland.nb)]

exceeds.ny.nb <- length(diff.in.diff.ny.placebo.nb[diff.in.diff.ny.placebo.nb>diff.in.diff.ny.actual.nb])  
less.than.ny.nb <- length(diff.in.diff.ny.placebo.nb)-exceeds.ny.nb

exceeds.nm.nb <- length(diff.in.diff.nm.placebo.nb[diff.in.diff.nm.placebo.nb>diff.in.diff.nm.actual.nb])  
less.than.nm.nb <- length(diff.in.diff.nm.placebo.nb)-exceeds.nm.nb

exceeds.Illinois.nb <- length(diff.in.diff.Illinois.placebo.nb[diff.in.diff.Illinois.placebo.nb>diff.in.diff.Illinois.actual.nb])  
less.than.Illinois.nb <- length(diff.in.diff.Illinois.placebo.nb)-exceeds.Illinois.nb

exceeds.Conn <- length(diff.in.diff.Conn.placebo[diff.in.diff.Conn.placebo>diff.in.diff.Conn.actual])  
less.than.Conn <- length(diff.in.diff.Conn.placebo)-exceeds.Conn

exceeds.NJ.nb <- length(diff.in.diff.NJ.placebo.nb[diff.in.diff.NJ.placebo.nb>diff.in.diff.NJ.actual.nb])  
less.than.NJ.nb <- length(diff.in.diff.NJ.placebo.nb)-exceeds.NJ.nb

exceeds.Delaware.nb <- length(diff.in.diff.Delaware.placebo.nb[diff.in.diff.Delaware.placebo.nb>diff.in.diff.Delaware.actual.nb])  
less.than.Delaware.nb <- length(diff.in.diff.Delaware.placebo.nb)-exceeds.Delaware.nb

exceeds.Maryland.nb <- length(diff.in.diff.Maryland.placebo.nb[diff.in.diff.Maryland.placebo.nb>diff.in.diff.Maryland.actual.nb])  
less.than.Maryland.nb <- length(diff.in.diff.Maryland.placebo.nb)-exceeds.Maryland.nb

container.matrix.nb <- matrix(nrow = 7, ncol = 5)
container.matrix.nb[1,] <- c("New York", round(diff.in.diff.ny.actual.nb, 2), exceeds.ny.nb, less.than.ny.nb, round((exceeds.ny.nb/28), 2))
container.matrix.nb[2,] <- c("New Mexico", round(diff.in.diff.nm.actual.nb, 2), exceeds.nm.nb, less.than.nm.nb, round((exceeds.nm.nb/24), 2))
container.matrix.nb[3,] <- c("Illinois", round(diff.in.diff.Illinois.actual.nb, 2), exceeds.Illinois.nb, less.than.Illinois.nb, round((exceeds.Illinois.nb/26), 2))
container.matrix.nb[4,] <- c("Connecticut", round(diff.in.diff.Conn.actual, 2), exceeds.Conn, less.than.Conn, round((exceeds.Conn/29), 2))
container.matrix.nb[5,] <- c("New Jersey", round(diff.in.diff.NJ.actual.nb, 2), exceeds.NJ.nb, less.than.NJ.nb, round((exceeds.NJ.nb/28), 2))
container.matrix.nb[6,] <- c("Delaware", round(diff.in.diff.Delaware.actual.nb, 2), exceeds.Delaware.nb, less.than.Delaware.nb, round((exceeds.Delaware.nb/28), 2))
container.matrix.nb[7,] <- c("Maryland", round(diff.in.diff.Maryland.actual.nb, 2), exceeds.Maryland.nb, less.than.Maryland.nb, round((exceeds.Maryland.nb/27), 2))


setwd("~/Desktop/Datasets")
execution.data <- read.csv("executions.in.abolition.states.csv")


par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))
plot(execution.data$Year[execution.data$State=="New York"], execution.data$Executions[execution.data$State=="New York"], main = "New York", ylim = c(0, 10))
abline(v=2004, col = "red")

plot(execution.data$Year[execution.data$State=="New Mexico"], execution.data$Executions[execution.data$State=="New Mexico"], main = "New Mexico", ylim = c(0, 10))
abline(v=2009, col = "red")
mtext("Figure X: Executions By State and Year", side = 3, line = 4, font = 2)

plot(execution.data$Year[execution.data$State=="Illinois"], execution.data$Executions[execution.data$State=="Illinois"], main = "Illinois", ylim = c(0, 10))
abline(v=2011, col = "red")

plot(execution.data$Year[execution.data$State=="Connecticut"], execution.data$Executions[execution.data$State=="Connecticut"], main = "Connecticut", ylim = c(0, 10))
abline(v=2012, col = "red")

plot(execution.data$Year[execution.data$State=="New Jersey"], execution.data$Executions[execution.data$State=="New Jersey"], main = "New Jersey", ylim = c(0, 10))
abline(v=2007, col = "red")

plot(execution.data$Year[execution.data$State=="Delaware"], execution.data$Executions[execution.data$State=="Delaware"], main = "Delaware", ylim = c(0, 10))
abline(v=2016, col = "red")

plot(execution.data$Year[execution.data$State=="Maryland"], execution.data$Executions[execution.data$State=="Maryland"], main = "Maryland", ylim = c(0, 10))
abline(v=2013, col = "red")

```

\noindent\textbf{Introduction}

For decades, social scientists have produced a vast literature on the deterrent effect of capital punishment (just a handful of the well-known studies include Sellin 1959; Ehrlich (1975 and 1977); Bowers & Pierce 1975; Ehrlich & Liu 1999; Lott & Landes 2000; Dezhbakhsh et al. 2003; Mocan & Gittings 2003; Liu 2004; Shepherd 2004; Donohue & Wolfers 2005; Zimmerman 2006; and Donohue & Wolfers 2009).  This research has proved enormously influential, surfacing in court cases, congressional testimony, and state-level debates over the death penalty.  Yet despite the number and prominence of these studies, scholars remain sharply divided.  Some find that executions deter a sizable number of homicides (e.g., Dezhbakhsh & Shepherd 2006; Zimmerman 2006; Shepherd 2004; Dezhbakhsh et al. 2003; Mocan & Gittings 2003) while others conclude that there is no solid evidence of a deterrent effect (e.g., National Research Council 2012; Donohue & Wolfers 2009; Kovandzic et al. 2009; Fagan 2006; Donohue & Wolfers 2005).  

Given the amount of ink already spilled over the question, one might naturally be skeptical of the ability of additional research to contribute to the already robust literature.  However, while the existing work is admirably rigorous and contains numerous useful insights, methodologically it remains somewhat homogeneous.  Researchers typically use traditional panel data methods (e.g., Kovandzic et al. 2009; Dezhbakhsh & Shepherd 2006; Shepherd 2004; Katz et al. 2003), with some of the older studies engaging in cross-sectional analysis (Ehrlich 1977).  While such techniques are undoubtedly valuable, it would be a mistake not to apply newer causal inference strategies to this important problem.  

This paper exploits one such method, the synthetic control design.  Developed in Abadie & Gardeazabal (2003) and expanded upon in Abadie et al. (2015; 2010), synthetic controls help solve the non-parallel trends problem that sometimes occurs in difference-in-differences studies.  Rather than using a single control unit, the synthetic control method uses a weighted combination of multiple untreated observations in order to construct a counterfactual that closely resembles the treated unit on a set of outcome variable predictors (Abadie & Gardeazabal 2003).  Since their introduction to the econometrics toolkit, synthetic controls have been successfully used to evaluate health care policies (Kreif et al. 2016), the economic impact of German reunification (Abadie et al. 2015), state right-to-work laws (Eren & Ozbeklik 2015), and the effect of permissive concealed handgun laws on violent crime (Donohue et al. 2019).  

In this case, I leverage seven states (Connecticut, Delaware, Illinois, Maryland, New Jersey, New Mexico, and New York) that abolished capital punishment between 1995 and 2018, and twenty-nine states that retained the death penalty throughout that period.^[I do not include Nebraska in this analysis, which repealed the death penalty in 2015 but reinstated it via referendum in 2016.  I also exclude Washington, which abolished capital punishment in 2018, the last year of my study.  Finally, the twelve states that had already eliminated capital punishment prior to 1995 play no role in this study.]  I run a synthetic control analysis for each abolitionist state, using placebo tests to perform statistical inference (Abadie et al. 2011).  I find no evidence that having the death penalty on the books decreases murder rates; indeed, for three states, the sign of the effect is in the opposite direction.  To fortify my conclusion, I conduct a number of robustness checks.  These include testing for anticipation effects, running alternative variable specifications, using a non-transformed version of the outcome variable, repeating my analyses using rates of stranger homicide (the type of murder most likely to be deterred by capital punishment) as the dependent variable, ruling out spillover effects, and utilizing the generalized synthetic control method suggested by Xu (2017).  

At the outset, the scope of my analyses should be made clear.  I am investigating whether having the death penalty on the books (the "de jure" death penalty) deters murder by itself—my primary analyses do not consider whether _executions_ prevent homicides.  While I provide some suggestive evidence in the discussion section that my null result occurs _because_ executions themselves do not deter, definitively establishing this claim is beyond the purview of this paper.  However, the question of whether merely having a capital punishment statute in place save lives is nonetheless extremely important.  "Symbolic" death penalty states—those with the death penalty but few executions—still often spend millions of dollars on the punishment (see, e.g., Steiker & Steiker 2016) and it is undoubtedly important to policymakers to understand whether they are receiving any increment of deterrence for this investment.

The remainder of this paper proceeds as follows.  In the next section, I provide a brief overview of the debate surrounding the death penalty’s deterrent effect.  I then turn to the existing empirical literature and consider previous attempts to measure the impact of capital punishment on homicide rates.  Next, I discuss my methodological approach and present the results of my analyses.  Finally, I conclude with a discussion of the public policy implications of this research.
   
\noindent\textbf{1. Background}

Capital punishment has long been a divisive subject in the United States.  In 1846, Michigan became the first state to eliminate the death penalty for ordinary crimes, and today twenty-three states have discarded the practice.  Support for capital punishment appears to have declined substantially in the U.S. in the first half of the twentieth century—in 1966, Gallup reported that more Americans opposed the punishment than favored it.  Perhaps influenced by the apparent shift in popular opinion, the Supreme Court struck down all state death penalty statutes in the 1972 case of _Furman v. Georgia_ [408 U.S. 238 (1972)], temporarily outlawing the punishment in the U.S.  However, pro-death penalty sentiment surged in the aftermath of that decision, and capital punishment has since enjoyed comfortable majority support nationally.^[For Gallup’s annual assessment of the death penalty’s popularity, see https://news.gallup.com/poll/1606/death-penalty.aspx.]  The Supreme Court approved a new generation of death penalty laws in its 1976 _Gregg v. Georgia_ [428 U.S. 153 (1976)] opinion, and the basic constitutional status of the institution has not changed in the years since (though the Supreme Court has limited the circumstances under which the punishment can be legally applied—see, for example, _Kennedy v. Louisiana_ [554 U.S. 207 (2008)]; _Atkins v. Virginia_ [536 U.S. 304 (2002)]; _Corker v. Georgia_ [433 U.S. 584 (1977)]).


The deterrent effect of capital punishment was—and continues to be—of interest to the courts when considering the status of the death penalty.  When the Supreme Court affirmed the constitutionality of the death penalty in _Gregg_, the Court’s controlling opinion identified deterrence as one of the main justifications for the punishment.  Likewise, in providing the decisive fifth vote against capital punishment in _Furman_, Justice White argued that the death penalty was too _infrequently_ imposed in the U.S. to act as a deterrent, and invalided existing statutes partially on that basis.  More recently, Supreme Court Justices like John Paul Stevens and Antonin Scalia have identified the potential deterrent effect of capital punishment as a major factor in determining its constitutionality.  In _Atkins v. Virginia_ [536 U.S. 304 (2002)], Justice Stevens observed that capital punishment can only be constitutionally applied if it contributes measurably to either deterrence or retribution.  In striking down the death penalty for individuals with serious intellectual disabilities, his opinion for the Court in _Atkins_ concluded that capital punishment did not contribute measurably to deterring murders when applied to that group.  Concurring in  _Baze v. Rees_ [553 U.S. 35 (2008)], Justice Stevens went one step further.  He argued that "[d]espite 30 years of empirical research in the area, there remains no reliable statistical evidence that capital punishment in fact deters potential offenders. In the absence of such evidence, deterrence cannot serve as a sufficient penological justification for this uniquely severe and irrevocable punishment."  In part because of this perceived lack of deterrence capacity, Justice Stevens indicated that he thought capital punishment violated the constitution (though he upheld the punishment on stare decisis grounds).  Responding to Justice Stevens, Justice Scalia pointed to research that showed capital punishment to be a substantial deterrent, and argued that it was the perogative of state legislators to consider this evidence in the context of their own local conditions.  

State judges are similarly concerned with the question—the Washington Supreme Court determined in 2018 that the death penalty violated the state constitution because it failed to contribute measurably to the goals of deterrence and retribution.  Consequently, new evidence concerning the deterrence question could affect judicial analysis at both the federal and state levels.

Given the undeniable importance of the question, it is unsurprising that scholars have repeatedly attempted to discern the deterrent effect of capital punishment.  Isaac Ehrlich’s 1975 article _The Deterrent Effect of Capital Punishment: A Question of Life and Death_ was an early rigorous attempt to do so.  Using national time-series data, Ehrlich attempted to model the “supply” of murders as a function of the risk of execution (among other factors).  While this approach was apparently influential at the time (earning Ehrlich a citation in _Gregg_), scholars have since dismissed it as incapable of identifying a causal relationship between capital punishment and murder (e.g., Donohue & Wolfers 2009; Fagan 2006).  

Work on the deterrent capacity of capital punishment continued through the 1980s and 1990s.  Papers by Layson (1985), Chressanthis (1989), Brumm and Cloninger (1996), and Ehrlich and Liu (1999) all found deterrent effects; work by Hoenack and Weiler (1980), Leamer (1983), McManus (1985), Cover and Thistel (1988), McAleer and Veal (1989), Grogger (1990), Bailey (1998), Albert (1999), Sorenson et al. (1999) did not. 

In the mid-to-late 2000s, however, a particularly influential series of studies emerged.  This research uses modern causal inference techniques and is widely seen as more credible than some of the earlier work.  Within this literature, there is a split with regard to the independent variable of interest; some studies take executions as their unit of analysis (e.g., Shepherd 2004; Dezhbakhsh et al. 2003), while others focus on the existence of death penalty statutes (e.g., Kovandzic et al. 2009; Dezhbakhsh & Shepherd 2006; Liu 2004).  Both are of independent theoretical interest—one might imagine that each execution itself contributes some increment of deterrence; that the mere existence of a death penalty statute prevents murder; both; or neither.  Another point of divergence is between studies that use instrumental variables (e.g., Zimmerman 2004; Dezhbakhsh et al. 2003) and those that rely on OLS with panel data (e.g., Katz et al. 2003).  The clearest divide, however, is between research that finds a deterrent effect and that which does not.  

Particularly prominent within the first set of articles are several studies by researchers Joanna Shepherd and Hashem Dezhbakhsh (working together and separately), starting with Dezhbakhsh et al. (2003).  That paper exploits county-level panel data running from 1977-2000 and takes a two-stage least squares approach.  Using variables like police payroll expenditures, expenditures on the judicial system, and prison admissions, the authors estimate the probability of arrest conditional on committing murder, the probability of conviction given arrest, and the probability of execution given conviction.  They then regress county-level murder rates on these estimates (plus standard demographic variables).  In each equation they estimate, the conditional probability of execution is negatively associated with murder rate—the authors interpret these results to mean that each execution deters an average of eighteen murders.  In an article published the next year on the same subject, Shepherd (2004) examines monthly state-level homicide data.  Deploying both OLS and negative binominal models, Shepherd determines that each execution prevents approximately three murders, and uncovers weaker evidence that death sentences deter murder independently of executions.  In later work, Shepherd (2005) argues that executions only deter murder if they are sufficiently numerous in the state—otherwise, she asserts, they have a “brutalizing” effect on society, leading to increasing rates of homicide.  The last paper in the Dezbakhsh/Shepherd series was Dezhbakhsh & Shepherd (2006), which seeks to estimate the impact of death penalty moratoriums on murder rates.  This article is particularly relevant to my current inquiry, as it suggests that the mere existence of the death penalty—rather than executions themselves—is associated with fewer murders.   

Several other researchers have used analogous methodologies to arrive at similar conclusions about the deterrent effect of capital punishment.  For example, Zimmerman (2004) uses a two-stage least squares technique reminiscent of Dezhbakhsh et al. (2003), and calculates that each execution prevents approximately fourteen murders.  Mocan & Gittings (2003) follow the same general approach, but consider commutations as well as executions; they find that commutations and executions have similar effects, spurring (or deterring) about five murders apiece. In yet another two-stage least squares analysis, Liu (2004) finds that the mere existence of the death penalty in a state is sufficient to provide deterrence.
	
On the other side of the ledger is an equally impressive battery of studies asserting either (1) that capital punishment does not lower murder rates or (2) that the studies demonstrating deterrence are flawed.  Donohue & Wolfers have two studies in the latter category (2009; 2005), which sharply criticize much of the existing death penalty literature.  Their 2009 paper revisits the analyses from Dezhbakhsh et al. (2003), Mocan & Gittings (2003), and Zimmerman (2004)—they conclude that the instruments deployed in each of these articles were either invalid or weak.  Donohue & Wolfers’ 2005 _Stanford Law Review_ article also takes these studies to task, and additionally raises questions about Dezhbakhsh & Shepherd (2006) and Shepherd (2004).   Regarding the former, they criticize the decision to use the pure number of executions (rather than executions per 100,000 residents) as the independent variable; in the case of the latter, they present evidence of a positive correlation between coefficient estimates and their standard errors (which they interpret as evidence of publication bias).  The 2012 National Research Council review of the literature considers the same articles discussed by Donohue & Wolfers and repeats much of the criticism those authors put forth.  Notably, however, many of the authors Donohue and Wolfers critique have since issued responses (see, e.g., Dezhbakhsh & Rubin 2011; Zimmerman 2010; Mocan & Gittings 2010; Zimmerman 2009).  For example, Dezhabkhsh and Rubin (2011, p.3668) charge that Donohue & Wolfers (2005) "is based on a selective sample, flawed analysis, biased reporting and violation of guidelines for objective sensitivity analysis."  Commenting on the debate between these scholars, Chalfin and coauthors dubbed the evidence on deterrence "inconclusive," and suggested using synthetic controls (Chalfin et al. 2013, p.41).

Other studies finding no deterrent effect include Kovandzic et al. (2009), Berk (2005), and Katz et al. (2003).  Using panel data running from 1977 to 2006, Kovandzic et al. find no evidence that the existence of death penalty statutes lowers murder rates, nor any support for the conclusion that executions prevent murder.  Katz et al. arrive at similar results using state-level data running from 1950-1990, finding that “the execution coefficient is extremely sensitive to the choice of specification and takes on a positive sign as frequently as a negative sign” (Katz et al. 2003, p.331).  Revisiting the work of scholars like Mocan & Gittings (2003), Berk (2005) concludes that a handful of “influence points” in the data (such as the large number of executions that occur annually in Texas) drive much of the evidence for death penalty deterrence.  One final study of note on this side of the debate is Fagan (2006), who finds that the results of Mocan & Gittings (2003) are extremely sensitive to alternative specifications and criticizes the deterrence literature more broadly.^[Additional studies questioning the deterrent capacity of the death penalty include Bailey (1998), Albert (1999), Sorenson et al. (1999), and Stolzenberg and D’Alessio (2004)]

While this review of previous research is necessarily partial, a few trends are already apparent.  First, the deterrent effect of capital punishment is hotly contested, with no clear scholarly consensus having yet emerged.  As such, despite the dozens of papers written on the subject, room remains for additional contributions to the literature.  Second—and perhaps more importantly for my purposes—existing papers tend to cluster around a small number of methodological techniques.  One of the most popular approaches appears to be two-stage least squares, with authors first estimating conditional probabilities for arrest, conviction, and execution, then modeling the murder supply using these probabilities and other demographic variables (e.g., Liu 2004; Zimmerman 2004; Dezhbakhsh et al. 2003).  A number of other studies use OLS (e.g., Kovandzic et al. 2009; Shepherd 2004; Katz et al. 2003), and only a handful of recent articles use more exotic methodologies (e.g., Land et al. 2009; Dezhbakhsh & Shepherd 2006; Stolzenberg & D’Alessio 2004).  Accordingly, applying a newer econometric technique should provide novel insight into this important question.^[While this paper was being revised, Mark Gius published a 10-page paper titled "Using the Synthetic Control Method to Determine the Effects of the Death Penalty on State-Level Murder Rates."  Gius applies the synthetic control technique to one of the seven states I consider here, New Jersey.  Unfortunately, the analysis in that article is haphazardly performed, and provides little-to-no insight into the deterrence debate.  The author does not provide the results of any placebo tests, uses an incomplete donor pool, constructs a poorly fitting synthetic control, appears to provide an inaccurate test for statistical significance, and does not conduct any serious robustness checks.  Unsurprisingly, the conclusions of the article deviate substantially from the results I present below.]  

\noindent\textbf{2. Methods and Data}

The synthetic control technique first appeared in Alberto Abadie and Javier Gardeazabal’s 2003 paper _The Economic Costs of Conflict: A Case Study of the Basque Country_.  In that article, the onset of terrorism in Spain’s Basque Country served as the treatment, with economic performance used as the outcome variable.  Seeking to improve on the standard difference-in-differences analysis, the authors assigned the sixteen untreated Spanish regions weights bounded between zero and one (and summing to one) to create a synthetic counterfactual—that is, a combination of control regions that closely resembled the Basque Country on twelve predictors of economic growth.^[As it happens, the optimal weights in this example were only non-zero for two control regions (Catalonia and Madrid).]  Comparing this synthetic control unit to the Basque Country in terms of real GDP per capita, Abadie & Gardeazabal present strong evidence that terrorism hindered the latter’s economic success.  

To implement the synthetic control method, researchers must seek a set of weights $W$ that minimizes ${\sum}_{m=1}^{k}{v}_{m}({X}_{1m}-{X}_{0m}{W})$ (Abadie et. al 2015).  In this equation, ${X}_{1m}$ is a vector of pre-intervention characteristics for the treated unit, and ${X}_{0m}$ is a matrix of pre-intervention characteristics for the control units.  The variable $m$ represents the m-th predictor, and $v$ is a vector of weights that represent how well a pre-intervention characteristic predicts the outcome variable.  In practice, researchers can choose $v$ using automated optimization.  Fortunately for applied researchers, statistical software packages like "synth" in R can now use optimization to select $W$ and $v$ in relatively short periods of time (see, e.g., Abadie et al. 2011).

One substantial advantage of the synthetic control model over the traditional difference-in-differences model concerns time-varying unobserved confounders (that is, variables that affect the outcome variable, change over time, and are not included in a difference-in-differences regression).  While the standard panel difference-in-differences approach is robust to time-invariant unobserved confounders, it fails in the case of uncontrolled varying confounders.  Synthetic controls eliminate this shortcoming (Abadie et al. 2011; Abadie et al. 2010), thus removing a substantial obstacle to causal inference.  This advantage stems from the inclusion of lagged outcome variables in the set of predictors used to create the synthetic control.  Unlike regression—where including lagged outcome variables in models is generally inadvisable—synthetic controls can and should account for these variables when generating counterfactuals (see, e.g., Renberg 2020; Botosaru & Ferman 2019; Bifulco et al. 2017; Abadie et al. 2015).  Since the synthetic control model is able to include these lagged dependent variables in generating counterfactuals, it can account for the influence of time-varying confounders on outcomes in a way that standard multivariate regression cannot.

This advantage of the synthetic control method is part of why the SCM—rather than the workhorse panel data—is the centerpiece of my analysis in this paper.  In Appendix D I present the results of running a generalized difference-in-differences model using my data.  It shows no evidence of deterrence; in fact, the coefficient for the variable "Death Penalty Statute" is large and positive, suggesting that having a capital punishment statute is associated with _higher_ murder rates (${\beta}$ = 0.055 log murders).  This result seems unlikely in light of the more sophisticated panel models from Dezhbakhsh & Shepherd (2006), and militates in favor of an empirical strategy that can avoid the problem of time-varying confounders.  

Though the SCM has some advantages over other causal inference strategies, several problems can still arise.  First, the method relies on the assumption that the value of the dependent variable in untreated units is unaffected by the treatment—that is, there are no spillover effects (Eren & Ozbeklik 2015).  This assumption might be violated, for example, if one individual in a household received an intervention (such as a campaign mailer) but another did not.  Since the untreated individual might still be impacted by the treatment (e.g., if the other household member discussed the mailer with them), the no-spillover assumption would be violated.  In the case of capital punishment statutes, however, this issue initially appears to be of limited concern.  It is unlikely that a potential murderer in North Carolina will care about the elimination of capital punishment in Maryland; she would not substantially alter her beliefs about the potential consequences of the in-state homicide she is contemplating.  Nevertheless, in order to address any residual concerns that abolishing capital punishment in one state could have an impact on murder rates in neighboring states, I conduct a robustness check later in the article in which border states are excluded from the pool of donor states (see Figure 9 and Table 9).

Another potential concern is the lack of sufficient pre or post-intervention data.  In a recent synthetic control primer, Abadie noted that “when designing a synthetic control study, it is of crucial importance to collect information on the affected unit and the donor pool for a large pre-treatment window” in order to limit estimator bias (Abadie, forthcoming).  Likewise, if the post-treatment period is too short, it may be impossible to observe the impact of the intervention despite the efficacy of the treatment.  In this study, inadequate pre-intervention data is not an issue; in every state I examine, data exists for at least nine years prior to the elimination of capital punishment.  In some of the seven abolitionist states I study, the post-treatment period is admittedly only a few years.  Some might think this concern is mitigated by the immediacy of the effect—the repeal of capital punishment in a state is often a major media event, and one might expect most potential murders to quickly become aware of the punishment's demise. However, others could reasonably disagree with this assumption, and maintain that a death penalty repeal would take longer to affect murder rates.  If the reader falls into that camp, I recommend focusing on states like New York and New Jersey—which do have sufficient post-intervention data—and treating the other analyses as merely suggestive, reported in this article for the sake of completeness.

A third issue with the use of synthetic controls is “anticipation.”  If individuals affected by treatment can anticipate its occurrence, they might alter their behavior during the pre-intervention period in ways that bias pre-period estimates of the outcome variable.  For instance, if would-be killers foresee the elimination of the death penalty in a state, they might not wait for formal legislative change before committing their crime.  As such, the effects of the treatment might be felt in the pre-intervention period, downward biasing estimates of a deterrent effect.  While this anticipation bias may seem implausible, it is important to account for this possibility.  Accordingly, I retest my results later in the paper with the date of abolition backdated two years.  Fortunately, when using synthetic controls, “backdating the intervention in the data does not mechanically bias the estimator of the effect of the intervention even if some periods before the intervention are mistakenly recorded as post-intervention periods” (Abadie, forthcoming).  

One final concern with the use of synthetic controls is that they inherently only measure the effect of an intervention in a single case, limiting the external validity of the results.  To understand this drawback, consider Abadie & Gardeazabal’s original 2003 paper.  While that article convincingly demonstrated the effect of terrorism on economic success in Spain, one might question whether its conclusions are applicable in other countries (such as France).  The treatment effect of terrorism might be heterogeneous or inconsistent depending on location.  Accordingly, while Abadie & Gardeazabal (2003) might provide our best estimate of how terrorism affects political subdivisions economically, we could reduce our uncertainty further if we drew from additional examples.  Happily, in the case under consideration here, we have seven treated units, allowing for multiple evaluations of the deterrent effect of capital punishment.

Having discussed the theory behind synthetic controls, I now turn to their application to the problem under study here.  To implement the technique, I collected data on a number of state-level variables mentioned in the literature as important predictors of murder (e.g., Kovadzic et al. 2009; Shepherd 2004; Zimmerman 2004).  These include the following: property crime rates (crimes/resident); unemployment rates; robbery rates (crimes/resident); population density; proportion of residents aged 15-29; real GDP per capita (2012 dollars); percentage of income held by the top 1% of earners (a measure of inequality); poverty rate (percentage in poverty); and direct police expenditures per capita.  Appendix A lists sources for each of these datasets.  The independent variable of interest in this study is, as mentioned, whether or not a state has a death penalty statute; the primary dependent variable of interest is log murders per 100,000 residents.^[I chose log murders per 100,000 residents rather than simply using murders per 100,000 residents in order to smooth the murder rate trends in smaller states (which can vary considerably from year-to-year).]

In addition to the predictors mentioned above, I also follow Abadie et al. (2010) by including three lagged years of the dependent variable as predictors.^[In this article, I often refer to "predictors" instead of variables.  Like a variable in the regression context, a predictor is a vector of observed values for a particular characteristic.  However, the term "predictor" highlights the role that the vectors play in constructing synthetic controls, and accordingly seems to be more common in synthetic control literature (see, e.g., Abadie et al. 2015; Abadie et al. 2010).]  As suggested in Appendix K of Donohue et al. (2019, NBER version), I selected (1) the year immediately prior to the abolition of the death penalty in treated states; (2) 1995 (the first year of the data); and (3) the midway point (or year closest to the midway point) between (1) and (2).  Some readers might be surprised to see pretreatment values of the outcome variable used as predictors—typically, methodologists caution against employing lagged dependent variables in empirical models.  However, when it comes to synthetic controls, it is actually standard practice to include such variables to improve model fit (e.g. Renberg 2020; Bifulco et al. 2017).  Experts in synthetic control methodology—including Abadie et. al (2015, p.497)—generally endorse using pretreatment outcome variables, and there is even scholarly discussion about which specific lags should be included (e.g., Botosaru & Ferman 2019; Kaul et al. 2016; Ferman & Pinto 2016).  Indeed, as mentioned above, inclusion of pre-treatment outcomes helps make the synthetic control robust to time-varying confounders (Abadie et al. 2015).  Accordingly, my primary specifications follow this practice.

Nevertheless, as robustness checks later in this work, I also test a version of the synthetic control analysis that uses no lags (see Figure 5 and Table 5). In addition, I consider models that use (a) the dependent variable average in the pre-treatment period as a predictor and (b) only the year prior to the treatment period as a predictor (again, see Donohue et al. 2019).  However, as discussed in more detail below, none of these alternative specifications change my substantive conclusions (see Figure 5 and Table 5).

Table 1 contains summary statistics for my predictor variables in the treated states (column 1).  For comparative purposes, I also provide summary statistics for the associated synthetic control (column 2), and the entire sample (i.e., the treated state and all the donor states) (column 3).  Unsurprisingly, the synthetic controls match each treated state far better than a simple unweighted average of the sample.  Most of the predictors contained in Table 1 run from 1995-2018—however, a few are only available for shorter periods (1995-2015 in the case of “Percentage of Income Held By Top 1%” and 1995-2017 in the case of “Direct Police Expenditures Per Capita”).^[New York reinstated its death penalty in 1995, which is why my dataset begins in that year.]  Since every variable runs at least through 2015, I perform the analyses using the years 1995-2015 for states eliminating the death penalty prior to 2010, which allows for a minimum of six post-treatment years in each case.  For states that abolished the death penalty after 2010 but before 2015, I perform the tests using the years 1995-2017, and forgo the inclusion of the “Percentage of Income Held By Top 1%” variable.  Finally, for states that jettisoned capital punishment after 2015, I run the analyses on the years 1995-2018, and include neither “Percentage of Income Held By Top 1%” nor “Direct Police Expenditures Per Capita.”  To carry out the empirical tests discussed in this paper, I use the “Synth” package in R developed by Alberto Abadie, Alexis Diamond, and Jens Hainmueller (see Abadie et al. 2011 for details).  

\newpage

\singlespacing
\begin{longtable}{cccc}
\toprule
\multicolumn{4}{c}{\bgroup\fontsize{12}{14}\selectfont \textbf{Table 1: Summary Statistics}\egroup{}} \\
\cmidrule(l{3pt}r{3pt}){1-4}
\begingroup\fontsize{12}{14}\selectfont \textbf{Predictor}\endgroup & \begingroup\fontsize{12}{14}\selectfont \textbf{Treated}\endgroup & \begingroup\fontsize{12}{14}\selectfont \textbf{Synthetic}\endgroup & \begingroup\fontsize{12}{14}\selectfont \textbf{Sample Mean}\endgroup\\
\midrule
\endfirsthead
\multicolumn{4}{@{}l}{\textit{(continued)}}\\
\toprule
\begingroup\fontsize{12}{14}\selectfont \textbf{Predictor}\endgroup & \begingroup\fontsize{12}{14}\selectfont \textbf{Treated}\endgroup & \begingroup\fontsize{12}{14}\selectfont \textbf{Synthetic}\endgroup & \begingroup\fontsize{12}{14}\selectfont \textbf{Sample Mean}\endgroup\\
\midrule
\endhead
\
\endfoot
\bottomrule
\endlastfoot
\addlinespace[0.3em]
\multicolumn{4}{l}{\textbf{New York (1995-2015)}}\\
\hspace{1em}Property crimes rates (crimes per resident) & 0.028 & 0.035 & 0.04\\
\hspace{1em}Unemployment rate (percentage) & 5.8 & 5.705 & 4.801\\
\hspace{1em}Robbery rate (crimes per resident) & 0.003 & 0.002 & \vphantom{1} 0.001\\
\hspace{1em}Population density & 395.163 & 183.812 & 101.416\\
\hspace{1em}Proportion aged 15 to 29 & 0.208 & 0.211 & 0.215\\
\hspace{1em}Real GDP per capita (2012 dollars) & 54928.796 & 46745.33 & 41261.222\\
\hspace{1em}Percentage of income held by top 1\% & 24.116 & 19.661 & 15.816\\
\hspace{1em}Poverty rate (percentage in poverty) & 15.2 & 12.622 & 12.688\\
\hspace{1em}Direct police expenditures per capita & 33.3 & 42.593 & 40.003\\
\hspace{1em}Log murders per 100,000 residents (2003) & 1.581 & 1.64 & 1.565\\
\hspace{1em}Log murders per 100,000 residents (1999) & 1.601 & 1.582 & 1.599\\
\hspace{1em}Log murders per 100,000 residents (1995) & 2.146 & 2.081 & 1.922\\
\hline
\addlinespace[0.3em]
\multicolumn{4}{l}{\textbf{New Mexico (1995-2015)}}\\
\hspace{1em}Property crimes rates (crimes per resident) & 0.046 & 0.041 & 0.038\\
\hspace{1em}Unemployment rate (percentage) & 5.527 & 5.171 & 4.937\\
\hspace{1em}Robbery rate (crimes per resident) & 0.001 & 0.001 & \vphantom{1} 0.001\\
\hspace{1em}Population density & 15.201 & 74.897 & 104.533\\
\hspace{1em}Proportion aged 15 to 29 & 0.215 & 0.222 & 0.214\\
\hspace{1em}Real GDP per capita (2012 dollars) & 40273.367 & 50324.15 & 43099.019\\
\hspace{1em}Percentage of income held by top 1\% & 13.566 & 17.213 & 16.557\\
\hspace{1em}Poverty rate (percentage in poverty) & 19.247 & 15.726 & 12.876\\
\hspace{1em}Direct police expenditures per capita & 63.8 & 56.079 & 41.308\\
\hspace{1em}Log murders per 100,000 residents (2008) & 2.093 & 2.103 & 1.552\\
\hspace{1em}Log murders per 100,000 residents (2002) & 2.105 & 2.082 & 1.515\\
\hspace{1em}Log murders per 100,000 residents (1995) & 2.172 & 2.225 & 1.922\\
\hline
\addlinespace[0.3em]
\multicolumn{4}{l}{\textbf{Illinois (1995-2017)}}\\
\hspace{1em}Property crimes rates (crimes per resident) & 0.034 & 0.039 & 0.037\\
\hspace{1em}Unemployment rate (percentage) & 6.029 & 6.042 & 5.429\\
\hspace{1em}Robbery rate (crimes per resident) & 0.002 & 0.002 & 0.001\\
\hspace{1em}Population density & 224.81 & 158.183 & 105.683\\
\hspace{1em}Proportion aged 15 to 29 & 0.212 & 0.212 & 0.213\\
\hspace{1em}Real GDP per capita (2012 dollars) & 51759.091 & 44760.459 & 43413.93\\
\hspace{1em}Poverty rate (percentage in poverty) & 11.771 & 14.298 & 13.159\\
\hspace{1em}Direct police expenditures per capita & 36.353 & 36.523 & 41.623\\
\hspace{1em}Log murders per 100,000 residents (2010) & 1.701 & 1.704 & 1.39\\
\hspace{1em}Log murders per 100,000 residents (2003) & 1.957 & 1.952 & 1.565\\
\hspace{1em}Log murders per 100,000 residents (1995) & 2.334 & 2.332 & 1.922\\
\hline
\addlinespace[0.3em]
\multicolumn{4}{l}{\textbf{Connecticut (1995-2017)}}\\
\hspace{1em}Property crimes rates (crimes per resident) & 0.028 & 0.037 & 0.037\\
\hspace{1em}Unemployment rate (percentage) & 5.267 & 5.147 & 5.563\\
\hspace{1em}Robbery rate (crimes per resident) & 0.001 & 0.001 & 0.001\\
\hspace{1em}Population density & 708.89 & 252.371 & 106.23\\
\hspace{1em}Proportion aged 15 to 29 & 0.188 & 0.191 & 0.213\\
\hspace{1em}Real GDP per capita (2012 dollars) & 64786.808 & 43083.427 & 43559.779\\
\hspace{1em}Poverty rate (percentage in poverty) & 8.883 & 10.886 & 13.286\\
\hspace{1em}Direct police expenditures per capita & 61.056 & 37.844 & 41.692\\
\hspace{1em}Log murders per 100,000 residents (2011) & 1.281 & 1.145 & 1.441\\
\hspace{1em}Log murders per 100,000 residents (2003) & 1.166 & 1.208 & 1.565\\
\hspace{1em}Log murders per 100,000 residents (1995) & 1.522 & 1.506 & 1.922\\
\hline
\addlinespace[0.3em]
\multicolumn{4}{l}{\textbf{New Jersey (1995-2015)}}\\
\hspace{1em}Property crimes rates (crimes per resident) & 0.029 & 0.035 & 0.039\\
\hspace{1em}Unemployment rate (percentage) & 5.046 & 4.982 & 4.772\\
\hspace{1em}Robbery rate (crimes per resident) & 0.002 & 0.001 & \vphantom{1} 0.001\\
\hspace{1em}Population density & 1128.432 & 269.007 & 103.314\\
\hspace{1em}Proportion aged 15 to 29 & 0.188 & 0.201 & 0.214\\
\hspace{1em}Real GDP per capita (2012 dollars) & 55701.855 & 44240.361 & 42609.768\\
\hspace{1em}Percentage of income held by top 1\% & 18.979 & 14.87 & 16.558\\
\hspace{1em}Poverty rate (percentage in poverty) & 8.223 & 11 & 12.706\\
\hspace{1em}Direct police expenditures per capita & 57.769 & 36.394 & 40.772\\
\hspace{1em}Log murders per 100,000 residents (2006) & 1.587 & 1.534 & 1.617\\
\hspace{1em}Log murders per 100,000 residents (2001) & 1.374 & 1.371 & 1.551\\
\hspace{1em}Log murders per 100,000 residents (1995) & 1.639 & 1.651 & 1.922\\
\hline
\addlinespace[0.3em]
\multicolumn{4}{l}{\textbf{Delaware (1995-2018)}}\\
\hspace{1em}Property crimes rates (crimes per resident) & 0.036 & 0.03 & 0.035\\
\hspace{1em}Unemployment rate (percentage) & 4.968 & 4.713 & 5.624\\
\hspace{1em}Robbery rate (crimes per resident) & 0.002 & 0.001 & 0.001\\
\hspace{1em}Population density & 430.248 & 52.593 & 108.307\\
\hspace{1em}Proportion aged 15 to 29 & 0.206 & 0.208 & 0.212\\
\hspace{1em}Real GDP per capita (2012 dollars) & 67774.688 & 44240.318 & 44246.082\\
\hspace{1em}Poverty rate (percentage in poverty) & 10.295 & 12.03 & 13.466\\
\hspace{1em}Log murders per 100,000 residents (2015) & 1.883 & 1.787 & 1.533\\
\hspace{1em}Log murders per 100,000 residents (2005) & 1.482 & 1.469 & 1.573\\
\hspace{1em}Log murders per 100,000 residents (1995) & 1.25 & 1.494 & 1.922\\
\hline
\addlinespace[0.3em]
\multicolumn{4}{l}{\textbf{Maryland (1995-2017)}}\\
\hspace{1em}Property crimes rates (crimes per resident) & 0.038 & 0.038 & 0.036\\
\hspace{1em}Unemployment rate (percentage) & 4.963 & 6.286 & 5.652\\
\hspace{1em}Robbery rate (crimes per resident) & 0.003 & 0.002 & 0.001\\
\hspace{1em}Population density & 561.464 & 113.405 & 106.76\\
\hspace{1em}Proportion aged 15 to 29 & 0.2 & 0.213 & 0.213\\
\hspace{1em}Real GDP per capita (2012 dollars) & 50902.115 & 49649.852 & 43706.068\\
\hspace{1em}Poverty Rate (percentage in poverty) & 8.916 & 14.45 & 13.368\\
\hspace{1em}Direct police expenditures per capita & 69.368 & 54.368 & 41.797\\
\hspace{1em}Log murders per 100,000 residents (2012) & 1.847 & 1.905 & 1.436\\
\hspace{1em}Log murders per 100,000 residents (2004) & 2.238 & 2.16 & 1.552\\
\hspace{1em}Log murders per 100,000 residents (1995) & 2.47 & 2.474 & 1.922\\*
\end{longtable}
\doublespacing

I will return to some of the points raised in this discussion as I walk through my findings.  For now, however, I will move on to examining the primary results of my analyses.  

\noindent\textbf{3. Primary Results}

Table 2 contains the weight each donor state received when constructing the synthetic controls used in the coming analyses.  The reader may note that relatively few states contribute to each synthetic control—the average was 3.9 donor states per analysis.^[The numbers in Table 2 are rounded to the hundredths place—accordingly, states that contributed less than 0.005 to a synthetic control appear as zeros, and I do not include them in my calculation of the average number of donor states per synthetic control.]  For one state, Illinois, the optimal synthetic control drew from nine donor states; for another, Delaware, it drew from only two.  It is not surprising that most of the synthetic controls draw from a small number of donor states.  In principle, of course, there is no reason why the number of donor states need be small—in Abadie et al. (2010), 37 states contribute some weight to a synthetic California.  In practice, though, the marginal returns of adding additional donor units often decrease quickly (Abadie et al. 2015), as some donor units simply tend to resemble the treated unit much more closely than others (see, e,g., Abadie & Gardeazabal 2003).  

\singlespacing
\begin{longtable}{c>{\bfseries\centering\arraybackslash}p{1.7cm}>{\bfseries\centering\arraybackslash}p{1.7cm}>{\bfseries\centering\arraybackslash}p{1.7cm}>{\bfseries\centering\arraybackslash}p{2.25cm}>{\bfseries\centering\arraybackslash}p{1.7cm}>{\bfseries\centering\arraybackslash}p{1.7cm}>{\bfseries\centering\arraybackslash}p{2.25cm}}
\toprule
\multicolumn{8}{c}{\bgroup\fontsize{14}{16}\selectfont \textbf{Table 2: Composition of Synthetic Controls}\egroup{}} \\
\cmidrule(l{3pt}r{3pt}){1-8}
\textbf{Donor State} & \textbf{Synthetic New York} & \textbf{Synthetic New Mexico} & \textbf{Synthetic Illinois} & \textbf{Synthetic Connecticut} & \textbf{Synthetic New Jersey} & \textbf{Synthetic Delaware} & \textbf{Synthetic Maryland}\\
\midrule
\endfirsthead
\multicolumn{8}{@{}l}{\textit{(continued)}}\\
\toprule
\textbf{Donor State} & \textbf{Synthetic New York} & \textbf{Synthetic New Mexico} & \textbf{Synthetic Illinois} & \textbf{Synthetic Connecticut} & \textbf{Synthetic New Jersey} & \textbf{Synthetic Delaware} & \textbf{Synthetic Maryland}\\
\midrule
\endhead
\
\endfoot
\bottomrule
\endlastfoot
Alabama & 0 & 0 & 0 & 0 & 0 & 0 & 0\\
Arizona & 0 & 0 & 0 & 0 & 0 & 0 & 0\\
Arkansas & 0 & 0 & 0 & 0 & 0 & 0 & 0\\
California & 0.73 & 0 & 0.25 & 0 & 0 & 0 & 0.07\\
Colorado & 0 & 0 & 0 & 0 & 0 & 0 & 0\\
\addlinespace
Florida & 0 & 0 & 0.09 & 0.58 & 0 & 0 & 0\\
Georgia & 0 & 0 & 0.05 & 0 & 0 & 0 & 0\\
Idaho & 0 & 0 & 0 & 0 & 0 & 0 & 0\\
Indiana & 0 & 0 & 0 & 0 & 0 & 0 & 0\\
Kansas & 0 & 0 & 0 & 0 & 0 & 0 & 0\\
\addlinespace
Kentucky & 0 & 0 & 0 & 0 & 0 & 0 & 0\\
Louisiana & 0 & 0.71 & 0.02 & 0 & 0 & 0 & 0.42\\
Mississippi & 0 & 0 & 0.11 & 0 & 0 & 0 & 0\\
Missouri & 0 & 0 & 0 & 0 & 0 & 0.57 & 0\\
Montana & 0 & 0 & 0 & 0 & 0 & 0 & 0\\
\addlinespace
Nevada & 0.09 & 0 & 0.11 & 0 & 0 & 0 & 0.34\\
New Hampshire & 0.18 & 0 & 0 & 0.34 & 0.05 & 0 & 0\\
North Carolina & 0 & 0 & 0 & 0 & 0 & 0 & 0\\
Ohio & 0 & 0 & 0.01 & 0 & 0.77 & 0 & 0\\
Oklahoma & 0 & 0 & 0 & 0 & 0 & 0 & 0\\
\addlinespace
Oregon & 0 & 0 & 0 & 0 & 0 & 0 & 0\\
Pennsylvania & 0 & 0 & 0 & 0.08 & 0.18 & 0 & 0.17\\
South Carolina & 0 & 0 & 0 & 0 & 0 & 0 & 0\\
South Dakota & 0 & 0.1 & 0 & 0 & 0 & 0.43 & 0\\
Tennessee & 0 & 0 & 0.29 & 0 & 0 & 0 & 0\\
\addlinespace
Texas & 0 & 0 & 0 & 0 & 0 & 0 & 0\\
Utah & 0 & 0 & 0 & 0 & 0 & 0 & 0\\
Virginia & 0 & 0 & 0.06 & 0 & 0 & 0 & 0\\
Wyoming & 0 & 0.17 & 0 & 0 & 0 & 0 & 0\\*
\end{longtable}
\doublespacing

The dotted lines in Figure 1 plot the value of the dependent variable (log murders per 100,000 residents) for each synthetic control over time; the solid lines plot the actual log murder rate for the state under study.  Reassuringly, the synthetic control closely approximates each treated unit in the years preceding the abolition of capital punishment.  The fits are particularly tight in more populated states with relatively smooth murder rates (New York, Illinois, and New Jersey).  Nevertheless, the control reasonably approximates the log murder rate even in small states with more year-to-year variance (New Mexico, Connecticut, and Delaware).  

```{r, echo=FALSE, warning=FALSE, fig.width=14, fig.align="center", fig.height=8, out.width="7in"}

### New York 

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))
path.plot(synth.res = synth.out, dataprep.res = new.york.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004, col = "red")

### New Mexico


path.plot(synth.res = synth.out.2, dataprep.res = nm.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009, col = "red")
mtext("Figure 1: Synthetic Control Plots for States That Eliminated Capital Punishment (y = Log Murders Per 100,000 Residents)", side = 3, line = 4, font = 2)

### Illinois 


path.plot(synth.res = synth.out.3, dataprep.res = Illinois.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011, col = "red")



### Connecticut


path.plot(synth.res = synth.out.4, dataprep.res = Conn.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012, col = "red")


### New Jersey


path.plot(synth.res = synth.out.5, dataprep.res = NJ.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007, col = "red")


### Delaware


path.plot(synth.res = synth.out.6, dataprep.res = Delaware.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016, col = "red")


### Maryland

path.plot(synth.res = synth.out.7, dataprep.res = Maryland.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013, col = "red")

legend.cols <- c("black", "black", "red")
names(legend.cols) <- c("Treated", "Synthetic Control", "Year Eliminated DP")
par(fig= c(0, 1, 0, 1), oma = c(0,0,0,0), mar = c(.5, .5, .5, .5), new=TRUE)
plot(0,0, type = "n", bty="n", xaxt ="n", yaxt="n")
legend("bottom", text.width=c(0.3,0.3,0.3), legend=names(legend.cols), col = legend.cols, lty = c(1,2,1), lwd = c(2.5, 2.5, 2.5), cex = .75, xpd = TRUE, horiz = F, inset = c(0,0,0), bty = "y", text.font = 2)

```

The most interesting aspect of Figure 1, of course, is not what happened in the pre-treatment period, but rather how murder rates change after the elimination of capital punishment.  The answer seems to be that they do not change, at least not in a direction indicating that capital punishment deters murder.  In two states, New Mexico and Connecticut, the log murder rate actually appears to _drop_ compared to the synthetic control.  In four others, the treated unit hugs the synthetic control almost as tightly in the post-treatment period as it did before treatment was implemented.  In only one state, Illinois, is there any hint that the murder rate may have increased relative to the synthetic control after capital punishment was eliminated.  Even so, the difference between the treated and control units is small, and only appears for two of the six post-treatment years.

Figure 2 reinforces the inference Figure 1 suggests.  It plots the gap between the treated state and the synthetic control for each of the seven abolitionist states.  Before treatment, the difference between the two units hovers around zero (the dotted line).  Accordingly, if death penalty statutes prevent murder, we would expect to see consistent positive values in years to the right of the red line in each panel of the figure.  Unsurprisingly given Figure 1, nothing of the sort occurs.  For the graphs of New Mexico and Connecticut, we see consistent _negative_ values—however, that trend indicates that eliminating the death penalty is associated with _fewer_ murders.  

```{r, echo=FALSE, warning=FALSE, fig.width=14, fig.align="center", fig.height=8, out.width="7in"}

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))
gaps.plot(synth.res = synth.out, dataprep.res = new.york.effect, Ylab = "", Xlab = "Year", Ylim = c(-1.5, 1.5), Main = "New York")
abline(v=2004, col = "red")


gaps.plot(synth.res = synth.out.2, dataprep.res = nm.effect, Ylab = "", Xlab = "Year", Ylim = c(-1.5, 1.5), Main = "New Mexico")
abline(v=2009, col = "red")
mtext("Figure 2: Gap Plots for States That Eliminated Capital Punishment (Y = Log Murder Rate Treated State - Log Murder Rate Synthetic Control)", side = 3, line = 4, font = 2)

gaps.plot(synth.res = synth.out.3, dataprep.res = Illinois.effect, Ylab = "", Xlab = "Year", Ylim = c(-1.5, 1.5), Main = "Illinois")
abline(v=2011, col = "red")

gaps.plot(synth.res = synth.out.4, dataprep.res = Conn.effect, Ylab = "", Xlab = "Year", Ylim = c(-1.5, 1.5), Main = "Connecticut")
abline(v=2012, col = "red")

gaps.plot(synth.res = synth.out.5, dataprep.res = NJ.effect, Ylab = "", Xlab = "Year", Ylim = c(-1.5, 1.5), Main = "New Jersey")
abline(v=2007, col = "red")

gaps.plot(synth.res = synth.out.6, dataprep.res = Delaware.effect, Ylab = "", Xlab = "Year", Ylim = c(-1.5, 1.5), Main = "Delaware")
abline(v=2016, col = "red")

gaps.plot(synth.res = synth.out.7, dataprep.res = Maryland.effect, Ylab = "", Xlab = "Year", Ylim = c(-1.5, 1.5), Main = "Maryland")
abline(v=2013, col = "red")

legend.cols <- c("black", "red")
names(legend.cols) <- c("Treated - Synthetic Control", "Year Eliminated DP")
par(fig= c(0, 1, 0, 1), oma = c(0,0,0,0), mar = c(.5, .5, .5, .5), new=TRUE)
plot(0,0, type = "n", bty="n", xaxt ="n", yaxt="n")
legend("bottom", text.width=c(0.3,0.3), legend=names(legend.cols), col = legend.cols, lty = c(1,1), lwd = c(2.5, 2.5), cex = .75, xpd = TRUE, horiz = F, inset = c(0,0), bty = "y", text.font = 2)

```


This series of graphs does not provide much evidence favoring the deterrence hypothesis (and least not in the types of states under study here—I return to this caveat in more detail in the Discussion section).  While there are individual points where the treated unit log murder rate exceeds the synthetic control, the average effect appears to be approximately zero in most cases.  Certainly nothing like the sustained deviations witnessed in Abadie et al. (2015, 2010) appears in any of these figures.  Simply put, when interpreted in the context of the synthetic control literature, these graphs do not justify deviating from the null hypothesis of no deterrent effect.

Nevertheless, mere visuals do not provide the more precise test of statistical significance one becomes used to seeing in empirical work.  Fortunately, the synthetic control literature has developed a substitute for this sort of analysis.  The solution put forth in Abadie et al. (2011; 2010) is iterative placebo tests.  For each of these placebo tests, a different potential donor state is analyzed _as if treated_; that is, I construct a synthetic control for each state that did not eliminate the death penalty, acting as though it did in fact abolish the death penalty in the same year the treated state did.  Performing this procedure provides me with 29 counterfactual estimates of the treatment effect for each state under study.  Figure 3 presents the results of this endeavor.

```{r, echo=FALSE, warning=FALSE, fig.width=14, fig.align="center", fig.height=8, out.width="7in"}

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))
black.red <- c(1:29, "purple")
plot.ts(final.ny, plot.type = "single", col = c(black.red), axes=F, xlab = "Year", ylab = "Difference Between Treated and Synthetic Control", lwd = c(rep(1, 29), 5), main = "New York Placebo Plot")
axis(2)
axis(1, labels = years, at = 1:24)
abline(h=0, lwd = 2, lty = 1, col = "blue")
abline(v = 10, lwd = 2, lty = 2, col = "red")
box()

black.red <- c(1:29, "purple")
plot.ts(final.NM, plot.type = "single", col = c(black.red), axes=F, xlab = "Year", ylab = "Difference Between Treated and Synthetic Control", lwd = c(rep(1, 29), 5), main = "New Mexico Placebo Plot")
axis(2)
axis(1, labels = years, at = 1:24)
abline(h=0, lwd = 2, lty = 1, col = "blue")
abline(v = 15, lwd = 2, lty = 2, col = "red")
box()
mtext("Figure 3: Placebo Gap Plots for States That Eliminated Capital Punishment (Y = Log Murder Rate Treated State - Log Murder Rate Synthetic Control)", side = 3, line = 4, font = 2)

black.red <- c(1:29, "purple")
plot.ts(final.Illinois, plot.type = "single", col = c(black.red), axes=F, xlab = "Year", ylab = "Difference Between Treated and Synthetic Control", lwd = c(rep(1, 29), 5), main = "Illinois Placebo Plot")
axis(2)
axis(1, labels = years, at = 1:24)
abline(h=0, lwd = 2, lty = 1, col = "blue")
abline(v = 17, lwd = 2, lty = 2, col = "red")
box()

black.red <- c(1:29, "purple")
plot.ts(final.Conn, plot.type = "single", col = c(black.red), axes=F, xlab = "Year", ylab = "Difference Between Treated and Synthetic Control", lwd = c(rep(1, 29), 5), main = "Connecticut Placebo Plot")
axis(2)
axis(1, labels = years, at = 1:24)
abline(h=0, lwd = 2, lty = 1, col = "blue")
abline(v = 18, lwd = 2, lty = 2, col = "red")
box()

black.red <- c(1:29, "purple")
plot.ts(final.NJ, plot.type = "single", col = c(black.red), axes=F, xlab = "Year", ylab = "Difference Between Treated and Synthetic Control", lwd = c(rep(1, 29), 5), main = "New Jersey Placebo Plot")
axis(2)
axis(1, labels = years, at = 1:24)
abline(h=0, lwd = 2, lty = 1, col = "blue")
abline(v = 13, lwd = 2, lty = 2, col = "red")
box()

black.red <- c(1:29, "purple")
plot.ts(final.Delaware, plot.type = "single", col = c(black.red), axes=F, xlab = "Year", ylab = "Difference Between Treated and Synthetic Control", lwd = c(rep(1, 29), 5), main = "Delaware Placebo Plot")
axis(2)
axis(1, labels = years, at = 1:24)
abline(h=0, lwd = 2, lty = 1, col = "blue")
abline(v = 22, lwd = 2, lty = 2, col = "red")
box()

black.red <- c(1:29, "purple")
plot.ts(final.maryland, plot.type = "single", col = c(black.red), axes=F, xlab = "Year", ylab = "Difference Between Treated and Synthetic Control", lwd = c(rep(1, 29), 5), main = "Maryland Placebo Plot")
axis(2)
axis(1, labels = years, at = 1:24)
abline(h=0, lwd = 2, lty = 1, col = "blue")
abline(v = 19, lwd = 2, lty = 2, col = "red")
box()

legend.cols <- c("yellow", "green", "pink", "purple", "red")
names(legend.cols) <- c("Placebo Difference-in-Differences", "Placebo Difference-in-Differences", "Placebo Difference-in-Differences", "Actual Difference-in-Differences", "Year Eliminated DP")
par(fig= c(0, 1, 0, 1), oma = c(0,0,0,0), mar = c(.5, .5, .5, .5), new=TRUE)
plot(0,0, type = "n", bty="n", xaxt ="n", yaxt="n")
legend("bottom", text.width=c(0.3,0.3,0.3), legend=names(legend.cols), col = legend.cols, lty = c(1,1,1,1,2), lwd = c(2.5, 2.5, 2.5, 5, 2.5), cex = .75, xpd = TRUE, horiz = F, inset = c(0,0,0), bty = "y", text.font = 2)

```

In each of the seven panels, it appears that the “treatment effect” of eliminating capital punishment is small relative to some of the placebo estimates.  As was the case with the gaps plotted in Figure 2, the difference between the log murder rate in most placebo states and their respective synthetic controls clustered around zero in the pre-period; post “treatment,” however, the differences often grew to be substantially greater than zero.  This trend indicates that large, positive “treatment” effects often occur by random chance when running placebo tests.  As such, the smaller (and sometimes negative) effects observed in the seven states under study can be appropriately read as evidence disfavoring a deterrent effect.

One might take this analysis even one step further by developing point estimates for the treatment effects presented in Figure 3.  To construct such a point estimate, I subtract the average difference between the treated and synthetic control units in the pre-period from their average in the post-period.  Mathematically,

${Estimated}$ ${Deterrence}$ $Effect$ = ${\frac{1}{{n}_{1}}}\sum_{i}^{n1}({{Treated}_{{1}{i}} - {Synthetic}_{{1}{i}}}) - {\frac{1}{{n}_{0}}}\sum_{i}^{n0}({{Treated}_{{0}{i}} - {Synthetic}_{{0}{i}}})$

In this equation, the subscript 1 represents the post-treatment period, the subscript 0 represents the pre-treatment period, ${n}_{1}$ is the number of post-treatment years, and ${n}_{0}$ is the number of pre-treatment years.  By calculating this quantity for all the estimates displayed in Figure 3, I can determine what fraction of placebo treatment effects exceed the true treatment effect in each state.  

Table 3 contains this information.  In column 1, I report estimated deterrent effects for each of the seven states that eliminated the death penalty; column 4 reports the fraction of placebo tests resulting in a larger estimated deterrent effect.

\singlespacing
\begin{longtable}{c>{\bfseries\centering\arraybackslash}p{2cm}>{\bfseries\centering\arraybackslash}p{2cm}>{\bfseries\centering\arraybackslash}p{2cm}>{\bfseries\centering\arraybackslash}p{2cm}}
\toprule
\multicolumn{5}{c}{\bgroup\fontsize{14}{16}\selectfont \textbf{Table 3: Permutation Tests of Effect Size}\egroup{}} \\
\cmidrule(l{3pt}r{3pt}){1-5}
\textbf{State} & \textbf{Estimated Deterrence Effect} & \textbf{Placebos With Larger Deterrence Effects} & \textbf{Placebos With Smaller Deterrence Effects} & \textbf{Proportion of Placebos With Larger Deterrence Effect}\\
\midrule
\endfirsthead
\multicolumn{5}{@{}l}{\textit{(continued)}}\\
\toprule
\textbf{State} & \textbf{Estimated Deterrence Effect} & \textbf{Placebos With Larger Deterrence Effects} & \textbf{Placebos With Smaller Deterrence Effects} & \textbf{Proportion of Placebos With Larger Deterrence Effect}\\
\midrule
\endhead
\
\endfoot
\bottomrule
\endlastfoot
New York & -0.04 & 15 & 14 & 0.52\\
New Mexico & -0.2 & 29 & 0 & 1\\
Illinois & 0.09 & 4 & 25 & 0.14\\
Connecticut & -0.17 & 27 & 2 & 0.93\\
New Jersey & 0.02 & 12 & 17 & 0.41\\
\addlinespace
Delaware & 0.01 & 12 & 17 & 0.41\\
Maryland & 0.03 & 17 & 12 & 0.59\\*
\end{longtable}
\doublespacing

As observed previously, some of the estimated deterrent effects are negative.  Here, a sigificant negative deterrent effect would indicate that removing the death penalty _decreased_ the logged murder rate. Table 3 does contain one such significant, negative deterrent rate: New Mexico, where the 0.20 unit decrease exceeds even the most negative estimates generated by the placebo tests. That -0.20 unit effect requires some translation—it cannot be understood without also knowing the mean log murder rate in the pre-period.  In New Mexico, the average murder rate before the abolition of capital punishment was about 8.4 murders per 100,000 residents (or about 2.13 log murders).  As such, the estimated deterrent effect of -0.20 log murders per 100,000 residents decreases the log murder rate to about 1.93 log murders, or about 6.9 murders per 100,000.  Accordingly, Table 3 suggests that eliminating capital punishment in New Mexico was associated with about 1.5 fewer murders per year per 100,000 residents.^[For reference, the average pre-period murder rates in the other states were as follows: New York: 5.6, Illinois: 7.2, Connecticut: 3.5, New Jersey: 4.3, Delaware: 6.1, Maryland: 6.5.]


```{r, include=F}

mean(NY$Murder.Rate[1:10])
mean(NM$Murder.Rate[1:15])
mean(Illinois$Murder.Rate[1:17])
mean(Conn$Murder.Rate[1:18])
mean(NJ$Murder.Rate[1:13])
mean(Delaware$Murder.Rate[22])
mean(Maryland$Murder.Rate[19])


```


Some might interpret the negative deterrent effect in New Mexico as a "brutalization effect."  The term "brutalization effect" has a specific meaning in the death penalty literature.  As Shepherd (2005, p.206) describes, "execution[s] [can] create[] a brutalization effect: [they] contribute[] to creating a climate of brutal violence. The execution sets an example of killing to avenge grievances, an example that some private individuals then follow."  In short, some might think that executions teach people to commit violent acts.  In this article, I am agnostic as to whether negative deterrence effects in fact provide evidence of brutalization—making that argument would require a theory of criminal psychology that goes beyond the scope of what is feasible here.  Instead, I treat negative deterrent effects merely as particularly strong evidence that the de jure death penalty does not prevent murder.

In some states listed in Table 3, the estimated deterrent effect was positive. However, even in those states, a substantial fraction of the placebo estimates were larger.  For every state aside from Illinois, New Jersey, and Delaware, more than half the placebo estimates were greater than the estimated deterrent effect.  In no state did the estimated deterrent effect exceed 90 percent of the placebo estimates, let alone the 95 percent that conventional definitions of statistical significance demand.   As such, my primary specifications do not provide any significant evidence of deterrence.

One alternative way of conducting causal inference with synthetic controls is to calculate root mean squared prediction errors (RMSPE)—defined as the square root of the mean squared difference between the log murder rates for the synthetic control and actual data—for pre and post-treatment periods for each of the placebo states and for the actual abolitionist state.  If eliminating the death penalty were to cause an increase in the murder rate, we would expect the ratio of post-period RMSPE to pre-period RMSPE to be higher in the abolitionist states than in the placebo states (Abadie et al. 2015).  This test is somewhat more difficult to interpret than the placebo tests in Table 3, because it does not specify the direction of the effect; if eliminating the death penalty _decreased_ murder rates, we would also expect to see a high post-period RMSPE to the pre-period RMSPE ratio.  However, it is still useful check, particular if the results are interpreted in the context of the information from Table 3.

Figure 4 presents the results of calculating _post-period RMSPE/pre-period RMSPE_.  In none of the seven panels does the treated state ratio stand out as particularly high when compared to the placebo ratios.  Maryland has the highest relative ratio, finishing 7th out of 30 states—however, that means a randomly selected placebo ratio would still be larger about 21 percent of the time.  Figure 4 thus suggests the same conclusion as Table 3—striking capital punishment from the statute books in these seven states did not increase the murder rate.

```{r, echo=FALSE, warning=FALSE, fig.width=14, fig.align="center", fig.height=8, out.width="7in"}

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))

dotchart(sort(rmpse.ratios.ny),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 18), "red", rep("black", 11)), cex = .4)

dotchart(sort(rmpse.ratios.nm),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 18), "red", rep("black", 11)), cex = .4)

mtext("Figure 4: Ratios of Post-Treatment RMSPE to Pre-Treatment RMSPE", side = 3, line = 4, font = 2)

dotchart(sort(rmpse.ratios.Illinois),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 21), "red", rep("black", 8)), cex = .4)

dotchart(sort(rmpse.ratios.Conn),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 22), "red", rep("black", 7)), cex = .4)

dotchart(sort(rmpse.ratios.NJ),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 11), "red", rep("black", 19)), cex = .4)

dotchart(sort(rmpse.ratios.Delaware),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 5), "red", rep("black", 25)), cex = .4)

dotchart(sort(rmpse.ratios.Maryland),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 23), "red", rep("black", 7)), cex = .4)



```

\noindent\textbf{4. Robustness}

To this point, none of the analyses performed in this article provide any evidence that the mere existence of capital punishment is sufficient to deter murder.  To solidify those findings, this section tests a wide variety of alternative specifications.  First, I consider the possibility that potential murderers anticipate the abolition of the death penalty, and commit their crimes without waiting for the formal elimination of the punishment (which would bias my results).  Second, I test alternative choices of lagged dependent variables, including models with _no_ lags.  Next, I try different sets of predictors, before moving to models that include (1) a non-logged version of the dependent variable and (2) stranger homicides as the outcome variable.  After doing so, I examine potential violations of the no-spillover assumption, and present models that guard against this possibility.  Finally, I analyze the data using Xu's generalized synthetic control method (GSCM), which allows for simultaneous consideration of multiple treated units (see Xu 2017).

I start by considering the possibility that the above tests do not adequately account for the possibility of anticipation.  That is, potential murderers might be aware that an elimination of the death penalty is on the horizon; for instance, they might read about the legislative debate on the subject in the newspaper, or hear politicians discuss the potential change during election season.  Anticipating the abolition of the punishment, these individuals might kill while the death penalty is still technically on the books.  This phenomenon would increase the pre-treatment murder rate, reducing the probability of finding a deterrent effect in the aftermath of the official change.  As mentioned in the accompanying footnote, it seems unlikely that would-be killers actually behave in this manner; nevertheless, conducting this robustness check can help address any residual doubts.^[As my colleagues have pointed out, it seems intuitively more probable that murderers who are planning their crimes well in advance would wait until the death penalty was off the books, rather than run the risk of execution.  However, if this were true, we would expect the murder rate to be artifically lower in the years preceding abolition and substantially higher in the years following it.  Such a phenomenon would bias my analyses _in favor_ of finding a deterrent effect.  Since I find no evidence that capital punishment prevents murders, this potential source of bias only makes my conclusions more robust.]

To account for this risk, I repeat the analyses performed above with the death penalty’s elimination backdated two years.^[In constructing synthetic controls for these analyses, I used the following lagged dependent variables: the year immediately prior to the new, backdated date of abolition (i.e., three years prior to the actual abolition date); (2) 1995 (the first year of the data); and (3) the midway point (or year closest to the midway point) between (1) and (2).]  As discussed in Abadie (forthcoming), this tactic accounts for the possibility of anticipation without mechanically biasing the effect estimator.  Below, I reproduce Figure 1 and Table 3 (now Figure 5 and Table 4) with this change implemented.  Doing so affects none of my substantive conclusions.


```{r, echo=FALSE, warning=FALSE, fig.width=14, fig.align="center", fig.height=8, out.width="7in"}

### New York 

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))
path.plot(synth.res = synth.out.robust, dataprep.res = new.york.effect.robust, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2002, col = "red")

### New Mexico


path.plot(synth.res = synth.out.2.robust, dataprep.res = nm.effect.robust, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2007, col = "red")
mtext("Figure 5: Testing for Anticipation Effects (y = Log Murders Per 100,000 Residents)", side = 3, line = 4, font = 2)

### Illinois 


path.plot(synth.res = synth.out.3.robust, dataprep.res = Illinois.effect.robust, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2009, col = "red")



### Connecticut


path.plot(synth.res = synth.out.4.robust, dataprep.res = Conn.effect.robust, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2010, col = "red")


### New Jersey


path.plot(synth.res = synth.out.5.robust, dataprep.res = NJ.effect.robust, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2005, col = "red")


### Delaware


path.plot(synth.res = synth.out.6.robust, dataprep.res = Delaware.effect.robust, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2014, col = "red")


### Maryland

path.plot(synth.res = synth.out.7.robust, dataprep.res = Maryland.effect.robust, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2011, col = "red")

legend.cols <- c("black", "black", "red")
names(legend.cols) <- c("Treated", "Synthetic Control", "Two Years Prior to DP Elimination")
par(fig= c(0, 1, 0, 1), oma = c(0,0,0,0), mar = c(.5, .5, .5, .5), new=TRUE)
plot(0,0, type = "n", bty="n", xaxt ="n", yaxt="n")
legend("bottom", text.width=c(0.3,0.3,0.3), legend=names(legend.cols), col = legend.cols, lty = c(1,2,1), lwd = c(2.5, 2.5, 2.5), cex = .75, xpd = TRUE, horiz = F, inset = c(0,0,0), bty = "y", text.font = 2)

```


\singlespacing
\begin{longtable}{c>{\bfseries\centering\arraybackslash}p{2cm}>{\bfseries\centering\arraybackslash}p{2cm}>{\bfseries\centering\arraybackslash}p{2cm}>{\bfseries\centering\arraybackslash}p{2cm}}
\toprule
\multicolumn{5}{c}{\bgroup\fontsize{12}{14}\selectfont \textbf{Table 4: Discontinuity Set 2 Years Prior to DP Elimination}\egroup{}} \\
\cmidrule(l{3pt}r{3pt}){1-5}
\textbf{State} & \textbf{Estimated Deterrence Effect} & \textbf{Placebos With Larger Deterrence Effects} & \textbf{Placebos With Smaller Deterrence Effects} & \textbf{Proportion of Placebos With Larger Deterrence Effect}\\
\midrule
\endfirsthead
\multicolumn{5}{@{}l}{\textit{(continued)}}\\
\toprule
\textbf{State} & \textbf{Estimated Deterrence Effect} & \textbf{Placebos With Larger Deterrence Effects} & \textbf{Placebos With Smaller Deterrence Effects} & \textbf{Proportion of Placebos With Larger Deterrence Effect}\\
\midrule
\endhead
\
\endfoot
\bottomrule
\endlastfoot
New York & -0.07 & 19 & 10 & 0.66\\
New Mexico & -0.04 & 17 & 12 & 0.59\\
Illinois & 0.11 & 3 & 26 & 0.1\\
Connecticut & -0.1 & 26 & 3 & 0.9\\
New Jersey & 0.04 & 10 & 19 & 0.34\\
\addlinespace
Delaware & 0.16 & 4 & 25 & 0.14\\
Maryland & -0.04 & 21 & 8 & 0.72\\*
\end{longtable}
\doublespacing

Next, I retest my results using different choices of lagged dependent variables.  I run specifications with (a) no lags; (b) the dependent variable average in the pre-treatment period as a predictor; and (c) the year prior to the treatment period as a predictor.  Table 5 provides the outcome of each analysis in the same format Table 3 utilizes.  Meanwhile, Figure 6 presents the results of the no lags model graphically (additional robustness checks for this model can be found in Appendix E).  Once again, none of these specifications reveal any statistically significant deterrent effect (if anything, some of the estimated deterrent effects become significant and _negative_ in alternative specifications).  Appendix C calculates the root mean squared prediction error (RMSPE)—again, the square root of the mean squared difference between the log murder rate for the synthetic control and actual data—during the pre-abolition period for each state under all three alternative specifications, as well as for my first model.  By this metric, the original model substantially outperforms each of the alternatives in terms of accuracy, which is part of why I use it as the primary specification (it also comports with standard practice in the field—see, e.g., Abadie et al. 2010).  

```{r, echo=FALSE, warning=FALSE, fig.width=14, fig.align="center", fig.height=8, out.width="7in"}

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))
path.plot(synth.res = synth.out.robust.2, dataprep.res = new.york.effect.robust.2, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004)


path.plot(synth.res = synth.out.2.robust.2, dataprep.res = nm.effect.robust.2, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009)
mtext("Figure 6: Constructing Synthetic Controls Without Lagged DVs (y = Log Murders Per 100,000 Residents)", side = 3, line = 4, font = 2)

path.plot(synth.res = synth.out.3.robust.2, dataprep.res = Illinois.effect.robust.2, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011)

path.plot(synth.res = synth.out.4.robust.2, dataprep.res = Conn.effect.robust.2, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012)


path.plot(synth.res = synth.out.5.robust.2, dataprep.res = NJ.effect.robust.2, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007)



path.plot(synth.res = synth.out.6.robust.2, dataprep.res = Delaware.effect.robust.2, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016)


path.plot(synth.res = synth.out.7.robust.2, dataprep.res = Maryland.effect.robust.2, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013)

```

\singlespacing
\begin{longtable}{c>{\centering\arraybackslash}p{2cm}>{\centering\arraybackslash}p{2cm}>{\centering\arraybackslash}p{2cm}>{\centering\arraybackslash}p{2cm}}
\toprule
\multicolumn{5}{c}{\bgroup\fontsize{14}{16}\selectfont \textbf{Table 5: Testing Alternative Specifications}\egroup{}} \\
\cmidrule(l{3pt}r{3pt}){1-5}
\textbf{State} & \textbf{Estimated Deterrence Effect} & \textbf{Placebos With Larger Deterrence Effects} & \textbf{Placebos With Smaller Deterrence Effects} & \textbf{Proportion of Placebos With Larger Deterrence Effect}\\
\midrule
\endfirsthead
\multicolumn{5}{@{}l}{\textit{(continued)}}\\
\toprule
\textbf{State} & \textbf{Estimated Deterrence Effect} & \textbf{Placebos With Larger Deterrence Effects} & \textbf{Placebos With Smaller Deterrence Effects} & \textbf{Proportion of Placebos With Larger Deterrence Effect}\\
\midrule
\endhead
\
\endfoot
\bottomrule
\endlastfoot
\addlinespace[0.3em]
\multicolumn{5}{l}{\textbf{No Lagged Dependent Variable as Predictor}}\\
\hspace{1em}New York & -0.28 & 28 & 1 & 0.97\\
\hspace{1em}New Mexico & -0.15 & 27 & 2 & 0.93\\
\hspace{1em}Illinois & 0.13 & 3 & 26 & 0.1\\
\hspace{1em}Connecticut & -0.17 & 27 & 2 & 0.93\\
\hspace{1em}New Jersey & 0.05 & 10 & 19 & 0.34\\
\hspace{1em}Delaware & 0.21 & 6 & 23 & 0.21\\
\hspace{1em}Maryland & 0.01 & 18 & 11 & \vphantom{1} 0.62\\
\addlinespace[0.3em]
\multicolumn{5}{l}{\textbf{Mean Pre-Period Log Murder Rate as Predictor}}\\
\hspace{1em}New York & -0.05 & 16 & 13 & \vphantom{1} 0.55\\
\hspace{1em}New Mexico & -0.16 & 27 & 2 & 0.93\\
\hspace{1em}Illinois & 0.12 & 4 & 25 & 0.14\\
\hspace{1em}Connecticut & -0.2 & 27 & 2 & 0.93\\
\hspace{1em}New Jersey & 0.02 & 10 & 19 & 0.34\\
\hspace{1em}Delaware & -0.01 & 18 & 11 & 0.62\\
\hspace{1em}Maryland & 0.01 & 17 & 12 & 0.59\\
\addlinespace[0.3em]
\multicolumn{5}{l}{\textbf{Year Prior to Abolition Log Murder Rate as Predictor}}\\
\hspace{1em}New York & -0.05 & 16 & 13 & 0.55\\
\hspace{1em}New Mexico & -0.15 & 28 & 1 & 0.97\\
\hspace{1em}Illinois & 0.11 & 4 & 25 & 0.14\\
\hspace{1em}Connecticut & -0.17 & 28 & 1 & 0.97\\
\hspace{1em}New Jersey & 0.05 & 9 & 20 & 0.31\\
\hspace{1em}Delaware & 0.09 & 10 & 19 & 0.34\\
\hspace{1em}Maryland & 0.01 & 18 & 11 & 0.62\\*
\end{longtable}
\doublespacing

I also consider models with alternative specifications for some of my primary predictor variables.  Using data from the FBI's Uniform Crime Reporting system, I replace the variable “Direct Police Expenditures Per Capita” with "Police Officers Per 1,000 Residents"; with data from the Prison Policy Initiative, I replace the "Robbery Rate" and "Property Crime Rate" variables with "Prisoners Per 100,000 Residents."^[I was not able to replace the crime rate variables with incarceration statistics for Delaware and Maryland, since the incaraceration statistics only run until 2015.  However, I was able to run the models with "Police Officers Per 1,000 Residents" for both states.]  Table 6 contains the results of running placebo tests using these replacement predictors; Appendix F has the associated graphs.  Choosing alternative predictors does not seem to have any substantial effect on the analysis; the statistics in Table 6 are similar to those in Table 3.

\singlespacing
\begin{longtable}{c>{\bfseries\centering\arraybackslash}p{2.5cm}>{\bfseries\centering\arraybackslash}p{2.5cm}>{\bfseries\centering\arraybackslash}p{2.5cm}>{\bfseries\centering\arraybackslash}p{2.5cm}}
\toprule
\multicolumn{5}{c}{\bgroup\fontsize{12}{14}\selectfont \textbf{Table 6: Permutation Tests of Effect Size, Alternative Predictor Variables}\egroup{}} \\
\cmidrule(l{3pt}r{3pt}){1-5}
\textbf{State} & \textbf{Estimated Deterrence Effect} & \textbf{Placebos With Larger Deterrence Effects} & \textbf{Placebos With Smaller Deterrence Effects} & \textbf{Proportion of Placebos With Larger Deterrence Effect}\\
\midrule
\endfirsthead
\multicolumn{5}{@{}l}{\textit{(continued)}}\\
\toprule
\textbf{State} & \textbf{Estimated Deterrence Effect} & \textbf{Placebos With Larger Deterrence Effects} & \textbf{Placebos With Smaller Deterrence Effects} & \textbf{Proportion of Placebos With Larger Deterrence Effect}\\
\midrule
\endhead
\
\endfoot
\bottomrule
\endlastfoot
New York & -0.05 & 19 & 10 & 0.66\\
New Mexico & -0.18 & 27 & 2 & 0.93\\
Illinois & 0.05 & 10 & 19 & 0.34\\
Connecticut & -0.17 & 28 & 1 & 0.97\\
New Jersey & 0.02 & 12 & 17 & 0.41\\
\addlinespace
Delaware & 0.01 & 14 & 15 & 0.48\\
Maryland & 0.03 & 13 & 16 & 0.45\\*
\end{longtable}
\doublespacing


```{r, include=F}


new.york.effect.diff.vars <- dataprep(foo = NY.Set, time.predictors.prior = c(1995:2004), predictors = c("prison.rate.n", "Unemployment.Rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "officer_rate_per_1000", "ny.lag.1", "ny.lag.5", "ny.lag.9"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 36, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 

synth.out.diff.vars <- synth(data.prep.obj = new.york.effect.diff.vars, method = "All")

ny.tables.diff.vars <- synth.tab(dataprep.res = new.york.effect.diff.vars, synth.res = synth.out.diff.vars)

path.plot(synth.res = synth.out.diff.vars, dataprep.res = new.york.effect.diff.vars, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004)

ny.gaps.diff.vars <- new.york.effect.diff.vars$Y1plot - (new.york.effect.diff.vars$Y0plot %*% synth.out.diff.vars$solution.w)


### New Mexico

nm.effect.diff.vars <- dataprep(foo = NM.Set, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "prison.rate.n", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "officer_rate_per_1000", "nm.lag.1", "nm.lag.7", "nm.lag.14"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 40, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 

synth.out.2.diff.vars <- synth(data.prep.obj = nm.effect.diff.vars, method = "All")

nm.tables.diff.vars <- synth.tab(dataprep.res = nm.effect.diff.vars, synth.res = synth.out.2.diff.vars)


path.plot(synth.res = synth.out.2.diff.vars, dataprep.res = nm.effect.diff.vars, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009)

nm.gaps.diff.vars <- nm.effect.diff.vars$Y1plot - (nm.effect.diff.vars$Y0plot %*% synth.out.2.diff.vars$solution.w)


### Illinois 

Illinois.effect.diff.vars <- dataprep(foo = Illinois.Set, time.predictors.prior = c(1995:2011), predictors = c("prison.rate.n", "Unemployment.Rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "officer_rate_per_1000", "illinois.lag.1", "illinois.lag.8", "illinois.lag.16"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 39, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 

synth.out.3.diff.vars <- synth(data.prep.obj = Illinois.effect.diff.vars, method = "All")

Illinois.tables.diff.vars <- synth.tab(dataprep.res = Illinois.effect.diff.vars, synth.res = synth.out.3.diff.vars)

path.plot(synth.res = synth.out.3.diff.vars, dataprep.res = Illinois.effect.diff.vars, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011)

Illinois.gaps.diff.vars <- Illinois.effect.diff.vars$Y1plot - (Illinois.effect.diff.vars$Y0plot %*% synth.out.3.diff.vars$solution.w)


### Connecticut

Conn.effect.diff.vars <- dataprep(foo = Conn.Set, time.predictors.prior = c(1995:2012), predictors = c("prison.rate.n", "Unemployment.Rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "officer_rate_per_1000", "conn.lag.1", "conn.lag.9", "conn.lag.17"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 41, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 

synth.out.4.diff.vars <- synth(data.prep.obj = Conn.effect.diff.vars, method = "All")

Conn.tables.diff.vars <- synth.tab(dataprep.res = Conn.effect.diff.vars, synth.res = synth.out.4.diff.vars)

path.plot(synth.res = synth.out.4.diff.vars, dataprep.res = Conn.effect.diff.vars, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012)

Conn.gaps.diff.vars <- Conn.effect.diff.vars$Y1plot - (Conn.effect.diff.vars$Y0plot %*% synth.out.4.diff.vars$solution.w)


### New Jersey

NJ.effect.diff.vars <- dataprep(foo = NJ.Set, time.predictors.prior = c(1995:2007), predictors = c("prison.rate.n", "Unemployment.Rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "officer_rate_per_1000", "nj.lag.1", "nj.lag.6", "nj.lag.12"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 42, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 

synth.out.5.diff.vars <- synth(data.prep.obj = NJ.effect.diff.vars, method = "All")

NJ.tables.diff.vars <- synth.tab(dataprep.res = NJ.effect.diff.vars, synth.res = synth.out.5.diff.vars)

path.plot(synth.res = synth.out.5.diff.vars, dataprep.res = NJ.effect.diff.vars, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007)

NJ.gaps.diff.vars <- NJ.effect.diff.vars$Y1plot - (NJ.effect.diff.vars$Y0plot %*% synth.out.5.diff.vars$solution.w)

### Delaware

Delaware.effect.diff.vars <- dataprep(foo = Delaware.Set, time.predictors.prior = c(1995:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "del.lag.1", "del.lag.11", "del.lag.21", "officer_rate_per_1000"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 38, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2016), time.plot = c(1995:2018)) 

synth.out.6.diff.vars <- synth(data.prep.obj = Delaware.effect.diff.vars, method = "All")

Delaware.tables.diff.vars <- synth.tab(dataprep.res = Delaware.effect.diff.vars, synth.res = synth.out.6.diff.vars)


path.plot(synth.res = synth.out.6.diff.vars, dataprep.res = Delaware.effect.diff.vars, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016)

Delaware.gaps.diff.vars <- Delaware.effect.diff.vars$Y1plot - (Delaware.effect.diff.vars$Y0plot %*% synth.out.6.diff.vars$solution.w)

### Maryland

Maryland.effect.diff.vars <- dataprep(foo = Maryland.Set, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "officer_rate_per_1000", "maryland.lag.1", "maryland.lag.9", "maryland.lag.18"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 37, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 

synth.out.7.diff.vars <- synth(data.prep.obj = Maryland.effect.diff.vars, method = "All")

path.plot(synth.res = synth.out.7.diff.vars, dataprep.res = Maryland.effect.diff.vars, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013)

Maryland.tables.diff.vars <- synth.tab(dataprep.res = Maryland.effect.diff.vars, synth.res = synth.out.7.diff.vars)

Maryland.gaps.diff.vars <- Maryland.effect.diff.vars$Y1plot - (Maryland.effect.diff.vars$Y0plot %*% synth.out.7.diff.vars$solution.w)



############### ############### ############### 
############### Single Plot ###############
############### ############### ############### 



### New York 

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))
path.plot(synth.res = synth.out.diff.vars, dataprep.res = new.york.effect.diff.vars, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004, col = "red")

### New Mexico


path.plot(synth.res = synth.out.2.diff.vars, dataprep.res = nm.effect.diff.vars, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009, col = "red")
mtext("Figure X: Synthetic Control Plots With Alternative Predictors (y = Log Murders Per 100,000 Residents)", side = 3, line = 4, font = 2)

### Illinois 


path.plot(synth.res = synth.out.3.diff.vars, dataprep.res = Illinois.effect.diff.vars, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011, col = "red")



### Connecticut


path.plot(synth.res = synth.out.4.diff.vars, dataprep.res = Conn.effect.diff.vars, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012, col = "red")


### New Jersey


path.plot(synth.res = synth.out.5.diff.vars, dataprep.res = NJ.effect.diff.vars, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007, col = "red")


### Delaware


path.plot(synth.res = synth.out.6.diff.vars, dataprep.res = Delaware.effect.diff.vars, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016, col = "red")


### Maryland

path.plot(synth.res = synth.out.7.diff.vars, dataprep.res = Maryland.effect.diff.vars, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013, col = "red")

legend.cols <- c("black", "black", "red")
names(legend.cols) <- c("Treated", "Synthetic Control", "Year Eliminated DP")
par(fig= c(0, 1, 0, 1), oma = c(0,0,0,0), mar = c(.5, .5, .5, .5), new=TRUE)
plot(0,0, type = "n", bty="n", xaxt ="n", yaxt="n")
legend("bottom", text.width=c(0.3,0.3,0.3), legend=names(legend.cols), col = legend.cols, lty = c(1,2,1), lwd = c(2.5, 2.5, 2.5), cex = .75, xpd = TRUE, horiz = F, inset = c(0,0,0), bty = "y", text.font = 2)


########################################
###### Adding to Placebo Gap Analysis ############
########################################

#### NY Placebo Prep
ny.placebos.diff.vars <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.ny <- dataprep(foo = death.set, time.predictors.prior = c(1995:2004), predictors = c("prison.rate.n", "Unemployment.Rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "officer_rate_per_1000", "ny.lag.1", "ny.lag.5", "ny.lag.9"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 
  synth.out.9 <- synth(data.prep.obj = death.set.effect.ny, method = "All")
  death.set.effect.ny.gaps <- death.set.effect.ny$Y1plot - (death.set.effect.ny$Y0plot %*% synth.out.9$solution.w);
  ny.placebos.diff.vars[,i] <- death.set.effect.ny.gaps
  i <- i + 1
}

final.ny.diff.vars <- cbind(ny.placebos.diff.vars, ny.gaps.diff.vars)
years <- seq(from=1995, to = 2018, by=1)

#### NM Placebo Prep
NM.placebos.diff.vars <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NM <- dataprep(foo = death.set, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "prison.rate.n", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "officer_rate_per_1000", "nm.lag.1", "nm.lag.7", "nm.lag.14"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 
  synth.out.10 <- synth(data.prep.obj = death.set.effect.NM, method = "All")
  death.set.effect.nm.gaps <- death.set.effect.NM$Y1plot - (death.set.effect.NM$Y0plot %*% synth.out.10$solution.w);
  NM.placebos.diff.vars[,i] <- death.set.effect.nm.gaps
  i <- i + 1
}

final.NM.diff.vars <- cbind(NM.placebos.diff.vars, nm.gaps.diff.vars)
years <- seq(from=1995, to = 2018, by=1)


#### Illinois Placebo Prep
Illinois.placebos.diff.vars <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Illinois <- dataprep(foo = death.set, time.predictors.prior = c(1995:2011), predictors = c("prison.rate.n", "Unemployment.Rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "officer_rate_per_1000", "illinois.lag.1", "illinois.lag.8", "illinois.lag.16"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 
  synth.out.11 <- synth(data.prep.obj = death.set.effect.Illinois, method = "All")
  death.set.effect.Illinois.gaps <- death.set.effect.Illinois$Y1plot - (death.set.effect.Illinois$Y0plot %*% synth.out.11$solution.w);
  Illinois.placebos.diff.vars[,i] <- death.set.effect.Illinois.gaps
  i <- i + 1
}

final.Illinois.diff.vars <- cbind(Illinois.placebos.diff.vars, Illinois.gaps.diff.vars)
years <- seq(from=1995, to = 2018, by=1)


#### Conn Placebo Prep
Conn.placebos.diff.vars <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Conn <- dataprep(foo = death.set, time.predictors.prior = c(1995:2012), predictors = c("prison.rate.n", "Unemployment.Rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "officer_rate_per_1000", "conn.lag.1", "conn.lag.9", "conn.lag.17"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 
  synth.out.12 <- synth(data.prep.obj = death.set.effect.Conn, method = "All")
  death.set.effect.Conn.gaps <- death.set.effect.Conn$Y1plot - (death.set.effect.Conn$Y0plot %*% synth.out.12$solution.w);
  Conn.placebos.diff.vars[,i] <- death.set.effect.Conn.gaps
  i <- i + 1
}

final.Conn.diff.vars <- cbind(Conn.placebos.diff.vars, Conn.gaps.diff.vars)
years <- seq(from=1995, to = 2018, by=1)


#### NJ Placebo Prep
NJ.placebos.diff.vars <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NJ <- dataprep(foo = death.set, time.predictors.prior = c(1995:2007), predictors = c("prison.rate.n", "Unemployment.Rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "officer_rate_per_1000", "nj.lag.1", "nj.lag.6", "nj.lag.12"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 
  synth.out.13 <- synth(data.prep.obj = death.set.effect.NJ, method = "All")
  death.set.effect.NJ.gaps <- death.set.effect.NJ$Y1plot - (death.set.effect.NJ$Y0plot %*% synth.out.13$solution.w);
  NJ.placebos.diff.vars[,i] <- death.set.effect.NJ.gaps
  i <- i + 1
}

final.NJ.diff.vars <- cbind(NJ.placebos.diff.vars, NJ.gaps.diff.vars)
years <- seq(from=1995, to = 2018, by=1)


#### Delaware Placebo Prep
Delaware.placebos.diff.vars <- matrix(nrow = 24, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Delaware <- dataprep(foo = death.set, time.predictors.prior = c(1995:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "del.lag.1", "del.lag.11", "del.lag.21", "officer_rate_per_1000"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2016), time.plot = c(1995:2018)) 
  synth.out.14 <- synth(data.prep.obj = death.set.effect.Delaware, method = "All")
  death.set.effect.Delaware.gaps <- death.set.effect.Delaware$Y1plot - (death.set.effect.Delaware$Y0plot %*% synth.out.14$solution.w);
  Delaware.placebos.diff.vars[,i] <- death.set.effect.Delaware.gaps
  i <- i + 1
}

final.Delaware.diff.vars <- cbind(Delaware.placebos.diff.vars, Delaware.gaps.diff.vars)
years <- seq(from=1995, to = 2018, by=1)

#### Maryland Placebo Prep


maryland.placebos.diff.vars <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.maryland <- dataprep(foo = death.set, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "officer_rate_per_1000", "maryland.lag.1", "maryland.lag.9", "maryland.lag.18"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 
  synth.out.8 <- synth(data.prep.obj = death.set.effect.maryland, method = "All")
  death.set.maryland.gaps <- death.set.effect.maryland$Y1plot - (death.set.effect.maryland$Y0plot %*% synth.out.8$solution.w);
  maryland.placebos.diff.vars[,i] <- death.set.maryland.gaps
  i <- i + 1
}


final.maryland.diff.vars  <- cbind(maryland.placebos.diff.vars, Maryland.gaps.diff.vars)
years <- seq(from=1995, to = 2018, by=1)

########################################
########## Permutation Calculations ##########
########################################

ny.pre.gaps.diff.vars <- final.ny.diff.vars[1:10,]
ny.post.gaps.diff.vars <- final.ny.diff.vars[11:nrow(final.ny.diff.vars),]

nm.pre.gaps.diff.vars <- final.NM.diff.vars[1:15,]
nm.post.gaps.diff.vars <- final.NM.diff.vars[16:nrow(final.NM.diff.vars),]

Illinois.pre.gaps.diff.vars <- final.Illinois.diff.vars[1:17,]
Illinois.post.gaps.diff.vars <- final.Illinois.diff.vars[18:nrow(final.Illinois.diff.vars),]

Conn.pre.gaps.diff.vars <- final.Conn.diff.vars[1:18,]
Conn.post.gaps.diff.vars <- final.Conn.diff.vars[19:nrow(final.Conn.diff.vars),]

NJ.pre.gaps.diff.vars <- final.NJ.diff.vars[1:13,]
NJ.post.gaps.diff.vars <- final.NJ.diff.vars[14:nrow(final.NJ.diff.vars),]

Delaware.pre.gaps.diff.vars <- final.Delaware.diff.vars[1:22,]
Delaware.post.gaps.diff.vars <- final.Delaware.diff.vars[23:nrow(final.Delaware.diff.vars),]

Maryland.pre.gaps.diff.vars <- final.maryland.diff.vars[1:19,]
Maryland.post.gaps.diff.vars <- final.maryland.diff.vars[20:nrow(final.maryland.diff.vars),]

diff.in.diff.ny.diff.vars <- colMeans(ny.post.gaps.diff.vars) - colMeans(ny.pre.gaps.diff.vars)
diff.in.diff.ny.placebo.diff.vars <- diff.in.diff.ny.diff.vars[1:(length(diff.in.diff.ny.diff.vars)-1)]
diff.in.diff.ny.actual.diff.vars <- diff.in.diff.ny.diff.vars[length(diff.in.diff.ny.diff.vars)]

diff.in.diff.nm.diff.vars <- colMeans(nm.post.gaps.diff.vars) - colMeans(nm.pre.gaps.diff.vars)
diff.in.diff.nm.placebo.diff.vars <- diff.in.diff.nm.diff.vars[1:(length(diff.in.diff.nm.diff.vars)-1)]
diff.in.diff.nm.actual.diff.vars <- diff.in.diff.nm.diff.vars[length(diff.in.diff.nm.diff.vars)]

diff.in.diff.Illinois.diff.vars <- colMeans(Illinois.post.gaps.diff.vars) - colMeans(Illinois.pre.gaps.diff.vars)
diff.in.diff.Illinois.placebo.diff.vars <- diff.in.diff.Illinois.diff.vars[1:(length(diff.in.diff.Illinois.diff.vars)-1)]
diff.in.diff.Illinois.actual.diff.vars <- diff.in.diff.Illinois.diff.vars[length(diff.in.diff.Illinois.diff.vars)]

diff.in.diff.Conn.diff.vars <- colMeans(Conn.post.gaps.diff.vars) - colMeans(Conn.pre.gaps.diff.vars)
diff.in.diff.Conn.placebo.diff.vars <- diff.in.diff.Conn.diff.vars[1:(length(diff.in.diff.Conn.diff.vars)-1)]
diff.in.diff.Conn.actual.diff.vars <- diff.in.diff.Conn.diff.vars[length(diff.in.diff.Conn.diff.vars)]

diff.in.diff.NJ.diff.vars <- colMeans(NJ.post.gaps.diff.vars) - colMeans(NJ.pre.gaps.diff.vars)
diff.in.diff.NJ.placebo.diff.vars <- diff.in.diff.NJ.diff.vars[1:(length(diff.in.diff.NJ.diff.vars)-1)]
diff.in.diff.NJ.actual.diff.vars <- diff.in.diff.NJ.diff.vars[length(diff.in.diff.NJ.diff.vars)]

diff.in.diff.Delaware.diff.vars <- colMeans(Delaware.post.gaps.diff.vars) - colMeans(Delaware.pre.gaps.diff.vars)
diff.in.diff.Delaware.placebo.diff.vars <- diff.in.diff.Delaware.diff.vars[1:(length(diff.in.diff.Delaware.diff.vars)-1)]
diff.in.diff.Delaware.actual.diff.vars <- diff.in.diff.Delaware.diff.vars[length(diff.in.diff.Delaware.diff.vars)]

diff.in.diff.Maryland.diff.vars <- colMeans(Maryland.post.gaps.diff.vars) - colMeans(Maryland.pre.gaps.diff.vars)
diff.in.diff.Maryland.placebo.diff.vars <- diff.in.diff.Maryland.diff.vars[1:(length(diff.in.diff.Maryland.diff.vars)-1)]
diff.in.diff.Maryland.actual.diff.vars <- diff.in.diff.Maryland.diff.vars[length(diff.in.diff.Maryland.diff.vars)]

exceeds.ny.diff.vars <- length(diff.in.diff.ny.placebo.diff.vars[diff.in.diff.ny.placebo.diff.vars>diff.in.diff.ny.actual.diff.vars])  
less.than.ny.diff.vars <- length(diff.in.diff.ny.placebo.diff.vars)-exceeds.ny.diff.vars

exceeds.nm.diff.vars <- length(diff.in.diff.nm.placebo.diff.vars[diff.in.diff.nm.placebo.diff.vars>diff.in.diff.nm.actual.diff.vars])  
less.than.nm.diff.vars <- length(diff.in.diff.nm.placebo.diff.vars)-exceeds.nm.diff.vars

exceeds.Illinois.diff.vars <- length(diff.in.diff.Illinois.placebo.diff.vars[diff.in.diff.Illinois.placebo.diff.vars>diff.in.diff.Illinois.actual.diff.vars])  
less.than.Illinois.diff.vars <- length(diff.in.diff.Illinois.placebo.diff.vars)-exceeds.Illinois.diff.vars

exceeds.Conn.diff.vars <- length(diff.in.diff.Conn.placebo.diff.vars[diff.in.diff.Conn.placebo.diff.vars>diff.in.diff.Conn.actual.diff.vars])  
less.than.Conn.diff.vars <- length(diff.in.diff.Conn.placebo.diff.vars)-exceeds.Conn.diff.vars

exceeds.NJ.diff.vars <- length(diff.in.diff.NJ.placebo.diff.vars[diff.in.diff.NJ.placebo.diff.vars>diff.in.diff.NJ.actual.diff.vars])  
less.than.NJ.diff.vars <- length(diff.in.diff.NJ.placebo.diff.vars)-exceeds.NJ.diff.vars

exceeds.Delaware.diff.vars <- length(diff.in.diff.Delaware.placebo.diff.vars[diff.in.diff.Delaware.placebo.diff.vars>diff.in.diff.Delaware.actual.diff.vars])  
less.than.Delaware.diff.vars <- length(diff.in.diff.Delaware.placebo.diff.vars)-exceeds.Delaware.diff.vars

exceeds.Maryland.diff.vars <- length(diff.in.diff.Maryland.placebo.diff.vars[diff.in.diff.Maryland.placebo.diff.vars>diff.in.diff.Maryland.actual.diff.vars])  
less.than.Maryland.diff.vars <- length(diff.in.diff.Maryland.placebo.diff.vars)-exceeds.Maryland.diff.vars

container.matrix.diff.vars <- matrix(nrow = 7, ncol = 5)
container.matrix.diff.vars[1,] <- c("New York", round(diff.in.diff.ny.actual.diff.vars, 2), exceeds.ny.diff.vars, less.than.ny.diff.vars, round((exceeds.ny.diff.vars/29), 2))
container.matrix.diff.vars[2,] <- c("New Mexico", round(diff.in.diff.nm.actual.diff.vars, 2), exceeds.nm.diff.vars, less.than.nm.diff.vars, round((exceeds.nm.diff.vars/29), 2))
container.matrix.diff.vars[3,] <- c("Illinois", round(diff.in.diff.Illinois.actual.diff.vars, 2), exceeds.Illinois.diff.vars, less.than.Illinois.diff.vars, round((exceeds.Illinois.diff.vars/29), 2))
container.matrix.diff.vars[4,] <- c("Connecticut", round(diff.in.diff.Conn.actual.diff.vars, 2), exceeds.Conn.diff.vars, less.than.Conn.diff.vars, round((exceeds.Conn.diff.vars/29), 2))
container.matrix.diff.vars[5,] <- c("New Jersey", round(diff.in.diff.NJ.actual.diff.vars, 2), exceeds.NJ.diff.vars, less.than.NJ.diff.vars, round((exceeds.NJ.diff.vars/29), 2))
container.matrix.diff.vars[6,] <- c("Delaware", round(diff.in.diff.Delaware.actual.diff.vars, 2), exceeds.Delaware.diff.vars, less.than.Delaware.diff.vars, round((exceeds.Delaware.diff.vars/29), 2))
container.matrix.diff.vars[7,] <- c("Maryland", round(diff.in.diff.Maryland.actual.diff.vars, 2), exceeds.Maryland.diff.vars, less.than.Maryland.diff.vars, round((exceeds.Maryland.diff.vars/29), 2))

sum.stats.diff.vars <- as.data.frame(container.matrix.diff.vars)


```

In addition to considering alternative predictor variables, it also makes sense to examine alternative dependent variable specifications.  As a first step in this direction, I re-run the models from Figure 1 and Table 3 using a non-logged version of the dependent variable.  In most of my analyses I use "log murders per 100,000 residents" as my outcome variable in order to smooth out considerable year-to-year variability in murder rates and produce better fits with my synthetic controls.  However, it is important to demonstrate that this modeling choice does not substantively affect the results of my placebo tests—to that end, I provide the same analyses with "murders per 100,000 residents" as the outcome variable.  As Figure 7 demonstrates, the synthetic control fit is considerably worse when using the non-logged dependent variable, but the placebo tests produce similar results (Table 7).  The only notable difference is that the p-value in Delaware increases substantially (to 0.79) and the effect estimate becomes negative.  The only significant result remains New Mexico, where eliminating the death penalty appears associated with a decrease in the murder rate.


```{r, echo=FALSE, warning=FALSE, fig.width=14, fig.align="center", fig.height=8, out.width="7in"}

### New York 

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))
path.plot(synth.res = synth.out.nl, dataprep.res = new.york.effect.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,15))
abline(v=2004, col = "red")

### New Mexico


path.plot(synth.res = synth.out.2.nl, dataprep.res = nm.effect.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,15))
abline(v=2009, col = "red")
mtext("Figure 7: Synthetic Control Plots for States That Eliminated Capital Punishment (y = Murders Per 100,000 Residents)", side = 3, line = 4, font = 2)

### Illinois 


path.plot(synth.res = synth.out.3.nl, dataprep.res = Illinois.effect.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,15))
abline(v=2011, col = "red")



### Connecticut


path.plot(synth.res = synth.out.4.nl, dataprep.res = Conn.effect.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,15))
abline(v=2012, col = "red")


### New Jersey


path.plot(synth.res = synth.out.5.nl, dataprep.res = NJ.effect.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,15))
abline(v=2007, col = "red")


### Delaware


path.plot(synth.res = synth.out.6.nl, dataprep.res = Delaware.effect.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,15))
abline(v=2016, col = "red")


### Maryland

path.plot(synth.res = synth.out.7.nl, dataprep.res = Maryland.effect.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,15))
abline(v=2013, col = "red")

legend.cols <- c("black", "black", "red")
names(legend.cols) <- c("Treated", "Synthetic Control", "Year Eliminated DP")
par(fig= c(0, 1, 0, 1), oma = c(0,0,0,0), mar = c(.5, .5, .5, .5), new=TRUE)
plot(0,0, type = "n", bty="n", xaxt ="n", yaxt="n")
legend("bottom", text.width=c(0.3,0.3,0.3), legend=names(legend.cols), col = legend.cols, lty = c(1,2,1), lwd = c(2.5, 2.5, 2.5), cex = .75, xpd = TRUE, horiz = F, inset = c(0,0,0), bty = "y", text.font = 2)

```

\singlespacing
\begin{longtable}{c>{\bfseries\centering\arraybackslash}p{2.5cm}>{\bfseries\centering\arraybackslash}p{2.5cm}>{\bfseries\centering\arraybackslash}p{2.5cm}>{\bfseries\centering\arraybackslash}p{2.5cm}}
\toprule
\multicolumn{5}{c}{\bgroup\fontsize{12}{14}\selectfont \textbf{Table 7: Permutation Tests of Effect Size, Non-Logged Dependent Variable}\egroup{}} \\
\cmidrule(l{3pt}r{3pt}){1-5}
\textbf{State} & \textbf{Estimated Deterrence Effect} & \textbf{Placebos With Larger Deterrence Effects} & \textbf{Placebos With Smaller Deterrence Effects} & \textbf{Proportion of Placebos With Larger Deterrence Effect}\\
\midrule
\endfirsthead
\multicolumn{5}{@{}l}{\textit{(continued)}}\\
\toprule
\textbf{State} & \textbf{Estimated Deterrence Effect} & \textbf{Placebos With Larger Deterrence Effects} & \textbf{Placebos With Smaller Deterrence Effects} & \textbf{Proportion of Placebos With Larger Deterrence Effect}\\
\midrule
\endhead
\
\endfoot
\bottomrule
\endlastfoot
New York & -0.21 & 17 & 12 & 0.59\\
New Mexico & -1.16 & 29 & 0 & 1\\
Illinois & 0.63 & 5 & 24 & 0.17\\
Connecticut & -0.54 & 27 & 2 & 0.93\\
New Jersey & 0.17 & 7 & 22 & 0.24\\
\addlinespace
Delaware & -0.53 & 23 & 6 & 0.79\\
Maryland & 0.21 & 15 & 14 & 0.52\\*
\end{longtable}
\doublespacing

As a more rigorous robustness check, I also repeat the analyses from Figure 1 and Table 3 using a different kind of dependent variable: rates of homicide by strangers.  As Shepherd (2004) notes, some believe that “murders committed during interpersonal disputes, murders by intimates, and noncontemplated crimes of passion are not intentionally committed and therefore cannot be deterred” (pp.283-84).  Accordingly, murders by strangers would theoretically be more susceptible to deterrence by capital punishment than other types of murders.  While it is worth noting that Shepherd reaches the opposite conclusion in her 2004 article, this conventional view remains pervasive (e.g., Fagan 2006).^[Given Shephard's findings, I also reran my analyses using "intimate homicide rate" and "acquaintance homicide rate" as dependent variables.  Appendix B contains the results of these tests—they are largely in line with the results presented here.]  Moreover, it seems that murders by strangers are more likely to be premeditated, and thus death-penalty eligible under the laws of various states.

To obtain rates of stranger homicide, I use the FBI’s Supplementary Homicide Reports as aggregated by Kaplan (2020).  This data contains background information for perhaps 90 percent of U.S. homicides, including location, demographic characteristics, and the victim(s)' relationship to the perpetrator(s) (see Fox & Swatt 2008 for additional description).  Of course, the dataset is necessarily incomplete, as murders often go unsolved.  Nevertheless, it is likely the best available source for disaggregated homicide information and is commonly used in the literature (e.g., Fridel & Fox 2019; Shepherd 2004).
	
Figure 8 and Table 8 below contain the results of this additional robustness check; stranger homicides per 100,000 residents is the dependent variable.^[To extract “stranger homicides per 100,000 residents” from the Supplementary Homicide Reports, I added the total number of individuals killed in incidents involving strangers for each state in each year, divided by the state’s population, and multiplied by 100,000.  It is important to note that the data—as compiled by Kaplan (2020)—is organized by “incident” and that multiple people might be murdered in a single incident (or a single person might be killed by multiple individuals).  Given the inherent difficulties associated with determining how to classify these rows of the dataset, I simply counted each homicide reported in an incident as a “stranger” homicide if at least one of the victims was a stranger to one of the offenders.  While this decision likely led to slight overestimates of the number of homicides that are truly “stranger” homicides, it was the best available solution to this disaggregation problem.  Moreover, if at least one of the deaths in the incident involved a “stranger” relationship, then all of the homicides in that incident were likely premeditated, and thus potentially subject to deterrence.]  Due to state-year missingness, I was only able to use 21 of the original 29 control states to construct the synthetic controls for this test.  In addition, the analysis for Delaware begins in 1996, as the Supplementary Homicide Reports does not contain data for Delaware in 1995.  Finally, I was also unable to perform a log transformation on this dependent variable (which would have helped smooth the data), as for some state-years, the stranger homicide rate was approximately zero.  Despite these limitations, the results are substantively similar to those obtained earlier—the post-period logged stranger murder rates in the treated states stay fairly close to the synthetic control estimates.

```{r, echo=FALSE, warning=FALSE, fig.width=14, fig.align="center", fig.height=8, out.width="7in"}

### New York 

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))
path.plot(synth.res = synth.out.stranger, dataprep.res = new.york.effect.stranger, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004, col = "red")

### New Mexico


path.plot(synth.res = synth.out.2.stranger, dataprep.res = nm.effect.stranger, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009, col = "red")
mtext("Figure 8: Synthetic Control Plots for States That Eliminated Capital Punishment (y = Stranger Murders Per 100,000 Residents)", side = 3, line = 4, font = 2)

### Illinois 


path.plot(synth.res = synth.out.3.stranger, dataprep.res = Illinois.effect.stranger, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011, col = "red")



### Connecticut


path.plot(synth.res = synth.out.4.stranger, dataprep.res = Conn.effect.stranger, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012, col = "red")


### New Jersey


path.plot(synth.res = synth.out.5.stranger, dataprep.res = NJ.effect.stranger, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007, col = "red")

### Delaware

path.plot(synth.res = synth.out.6.stranger, dataprep.res = Delaware.effect.stranger, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016, col = "red")


### Maryland

path.plot(synth.res = synth.out.7.stranger, dataprep.res = Maryland.effect.stranger, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013, col = "red")

legend.cols <- c("black", "black", "red")
names(legend.cols) <- c("Treated", "Synthetic Control", "Year Eliminated DP")
par(fig= c(0, 1, 0, 1), oma = c(0,0,0,0), mar = c(.5, .5, .5, .5), new=TRUE)
plot(0,0, type = "n", bty="n", xaxt ="n", yaxt="n")
legend("bottom", text.width=c(0.3,0.3,0.3), legend=names(legend.cols), col = legend.cols, lty = c(1,2,1), lwd = c(2.5, 2.5, 2.5), cex = .75, xpd = TRUE, horiz = F, inset = c(0,0,0), bty = "y", text.font = 2)
```

The synthetic controls do not fit the stranger homicide data quite as well as they do the overall homicide data—this mismatch is likely because stranger homicides comprise a relatively small proportion of overall homicides and are thus extremely variable year-to-year.  However, some of Figure 8’s panels (such as New Jersey and New Mexico) do reveal appropriately tight fits.

\singlespacing
\begin{longtable}{c>{\bfseries\centering\arraybackslash}p{2.5cm}>{\bfseries\centering\arraybackslash}p{2.5cm}>{\bfseries\centering\arraybackslash}p{2.5cm}>{\bfseries\centering\arraybackslash}p{2.5cm}}
\toprule
\multicolumn{5}{c}{\bgroup\fontsize{14}{16}\selectfont \textbf{Table 8: Permutation Tests of Effect Size, Stranger Homicides}\egroup{}} \\
\cmidrule(l{3pt}r{3pt}){1-5}
\textbf{State} & \textbf{Estimated Deterrence Effect} & \textbf{Placebos With Larger Deterrence Effects} & \textbf{Placebos With Smaller Deterrence Effects} & \textbf{Proportion of Placebos With Larger Deterrence Effect}\\
\midrule
\endfirsthead
\multicolumn{5}{@{}l}{\textit{(continued)}}\\
\toprule
\textbf{State} & \textbf{Estimated Deterrence Effect} & \textbf{Placebos With Larger Deterrence Effects} & \textbf{Placebos With Smaller Deterrence Effects} & \textbf{Proportion of Placebos With Larger Deterrence Effect}\\
\midrule
\endhead
\
\endfoot
\bottomrule
\endlastfoot
New York & -0.31 & 19 & 2 & 0.9\\
New Mexico & 0.14 & 5 & 16 & 0.24\\
Illinois & 0.08 & 6 & 15 & 0.29\\
Connecticut & -0.05 & 11 & 10 & 0.52\\
New Jersey & -0.02 & 11 & 10 & 0.52\\
\addlinespace
Delaware & -0.21 & 19 & 2 & 0.9\\
Maryland & -0.13 & 14 & 7 & 0.67\\*
\end{longtable}
\doublespacing

The placebo tests results presented in Table 8 validate the visual evidence from Figure 8.  In no case does the estimated deterrent effect approach conventional standards of statistical significance (the lowest p-value is .24) and five of the seven estimated effects are negative.  As such, even when I limit the data to the type of homicide that seems most susceptible to deterrence, I still find no evidence that capital punishment statutes prevent murders.  

The next robustness check I conduct seeks to account for potential violations of the no-spillover assumption mentioned in the methods discussion.  While that assumption seems fairly straightforward—after all, in most cases, criminals are primarily concerned with the laws in their own state—one still might be concerned that potential murderers in one state will revise their punishment expectations after learning about abolition in a neighboring jurisdiction.  For instance, a potential killer in Pennsylvania might consider the elimination of the New York death penalty to be a sign that abolition may soon come to his state.  At the suggestion of anonymous reviewers, I address this concern by replicating the analysis in Figure 1 and Table 3 with bordering states eliminated from the donor pool.  That is, when constructing the synthetic control for New Mexico, I did not use Texas, Oklahoma, Colorado, Utah, or Arizona.  Figure 9 and Table 9 present the results of these analyses—they strongly resemble those from my primary specifications.

```{r, echo=FALSE, warning=FALSE, fig.width=14, fig.align="center", fig.height=8, out.width="7in"}

### New York 

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))
path.plot(synth.res = synth.out.nb, dataprep.res = new.york.effect.nb, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004, col = "red")

### New Mexico


path.plot(synth.res = synth.out.2.nb, dataprep.res = nm.effect.nb, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009, col = "red")
mtext("Figure 9: Strengthening No-Spillover Assumption By Removing Bordering States (y = Log Murders Per 100,000 Residents)", side = 3, line = 4, font = 2)

### Illinois 


path.plot(synth.res = synth.out.3.nb, dataprep.res = Illinois.effect.nb, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011, col = "red")



### Connecticut


path.plot(synth.res = synth.out.4, dataprep.res = Conn.effect, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012, col = "red")


### New Jersey


path.plot(synth.res = synth.out.5.nb, dataprep.res = NJ.effect.nb, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007, col = "red")


### Delaware


path.plot(synth.res = synth.out.6.nb, dataprep.res = Delaware.effect.nb, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016, col = "red")


### Maryland

path.plot(synth.res = synth.out.7.nb, dataprep.res = Maryland.effect.nb, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013, col = "red")

legend.cols <- c("black", "black", "red")
names(legend.cols) <- c("Treated", "Synthetic Control", "Year Eliminated DP")
par(fig= c(0, 1, 0, 1), oma = c(0,0,0,0), mar = c(.5, .5, .5, .5), new=TRUE)
plot(0,0, type = "n", bty="n", xaxt ="n", yaxt="n")
legend("bottom", text.width=c(0.3,0.3,0.3), legend=names(legend.cols), col = legend.cols, lty = c(1,2,1), lwd = c(2.5, 2.5, 2.5), cex = .75, xpd = TRUE, horiz = F, inset = c(0,0,0), bty = "y", text.font = 2)



```

\singlespacing
\begin{longtable}{c>{\bfseries\centering\arraybackslash}p{2.5cm}>{\bfseries\centering\arraybackslash}p{2.5cm}>{\bfseries\centering\arraybackslash}p{2.5cm}>{\bfseries\centering\arraybackslash}p{2.5cm}}
\toprule
\multicolumn{5}{c}{\bgroup\fontsize{12}{14}\selectfont \textbf{Table 9: Permutation Tests of Effect Size, No Border States Used as Donors}\egroup{}} \\
\cmidrule(l{3pt}r{3pt}){1-5}
\textbf{State} & \textbf{Estimated Deterrence Effect} & \textbf{Placebos With Larger Deterrence Effects} & \textbf{Placebos With Smaller Deterrence Effects} & \textbf{Proportion of Placebos With Larger Deterrence Effect}\\
\midrule
\endfirsthead
\multicolumn{5}{@{}l}{\textit{(continued)}}\\
\toprule
\textbf{State} & \textbf{Estimated Deterrence Effect} & \textbf{Placebos With Larger Deterrence Effects} & \textbf{Placebos With Smaller Deterrence Effects} & \textbf{Proportion of Placebos With Larger Deterrence Effect}\\
\midrule
\endhead
\
\endfoot
\bottomrule
\endlastfoot
New York & -0.04 & 28 & 0 & 1\\
New Mexico & -0.17 & 23 & 1 & 0.96\\
Illinois & 0.09 & 3 & 23 & 0.12\\
Connecticut & -0.17 & 27 & 2 & 0.93\\
New Jersey & 0.02 & 15 & 13 & 0.54\\
\addlinespace
Delaware & 0.03 & 13 & 15 & 0.46\\
Maryland & 0.06 & 11 & 16 & 0.41\\*
\end{longtable}
\doublespacing

The final means I use to test the robustness of my results is the generalized synthetic control method (GSCM) suggested by Xu (2017).  Xu developed the GSCM method as a means of unifying the synthetic control method with linear fixed effects models.  According to Xu (2017, p.58), "[t]his method is in the spirit of the synthetic control method in the sense that by essence it is a reweighting scheme that takes pretreatment treated outcomes as benchmarks when choosing weights for control units and uses cross-sectional correlations between treated and control units to predict treated counterfactuals. Unlike the synthetic matching method, however, it conducts dimension reduction prior to reweighting such that vectors to be reweighted on are smoothed across control units."  That paper provides a more expansive description of the GSCM; for our purposes, however, it can be treated as similar to the standard synthetic control analysis, with the exception that it considers multiple units simultaneously (see, e.g., Gilens et al. 2021; Bischof & Wagner 2019).  The GSCM method has two major advantages compared to ordinary synthetic controls.  The first is the aforementioned ability to account for multiple treated units simultaneously; the second is its ability to provide confidence intervals for the effect estimates without the laborious iterative placebo process described above.

Figure 10 provides the results of running this GSCM model—I exclude New York, because the GSCM approach prefers a minimum of 10 years pre-treatment (Bischof & Wagner 2019; Xu 2017).  The x-axis represents years prior to (or succeeding) the abolition of capital punishment, while the y-axis represents the average treatment effect on the treated (the ATT).  Positive values represent increases in the log murder rate in the treated states (relative to untreated states), while negative values represent decreases.  In other words, Figure 10 is a generalized version of Figure 2.  

```{r, echo=FALSE, warning=FALSE, fig.width=14, fig.align="center", fig.height=8, out.width="7in"}

plot(gsynth.object.one, main = "Figure 10: Generalized Synthetic Control, Gap Plot", xlab = "Years Preceding and Following Death Penalty Abolition", ylab = "Estimated Deterrence Effect (Change in Logged Murder Rate)")

```

In the pre-treatment period (negative values on the x-axis), the ATT hovers around 0 (as it should, given that no state in the sample had yet abolished capital punishment).  In the post-treatment period, the ATT becomes slightly negative, indicating that abolishing the death penalty is associated with a decrease in murder rates.  However, as the confidence intervals indicate, this putative effect is not statistically significant.  Using the "Gsynth" package in R, I was able to extract the average ATT and its standard error—those values were -0.07 and 0.11, respectively (p = 0.59).  Nevertheless, the GSCM results tell the same story as the preceeding tests: there is no significant evidence that the de jure death penalty deters murder.

\noindent\textbf{5. Discussion}

The foregoing analyses indicate that having a capital punishment statute on the books in a state does not, by itself, deter murders.  In the seven states considered here, post-abolition murder rates closely track the synthetic control trends.  In fact, in the two states that deviated most from the synthetic control in the post-treatment period (Connecticut and New Mexico), eliminating the death penalty was associated with _fewer_ murders.  These results are robust to multiple alternative specifications, do not appear to be the result of anticipation, and persist when the data is limited to the homicides theoretically most susceptible to deterrence.

It is important to note, however, that this study should be read with several qualifications in mind.  First, one might raise questions about the reliability of the estimates for Illinois and Delaware.  In Illinois, Governor George Ryan imposed a moratorium on executions in 2000.  As such, though the death penalty remained a legally sanctioned punishment until 2011, there was no threat of execution between 2000 and that date.  While the state did continue to seek death sentences during the moratorium period—meaning that a potential murderer could not be sure they would never be executed in Illinois for their crime—some might be concerned that the official halt to executions was itself sufficient to lessen the deterrent effect of capital punishment.^[I address the impact of the Illinois moratorium below—for the moment, it is sufficient to note that backdating the abolition of the Illinois death penalty to 2000 does not change my results.]

Meanwhile, one might have the opposite concern in the case of Delaware.  That state’s 2016 elimination of capital punishment leaves only two years of post-treatment data.  Though I would expect the putative deterrent effect of the death penalty to evaporate immediately upon the abolition of the punishment, some may disagree.  If those individuals are correct, then little could be gleaned from my study of Delaware.  We simply would not have enough post-period observations to make meaningful inferences.  Fortunately, my work does not turn entirely on the study of Delaware or Illinois—if both were excluded, results from five other states would still support the conclusions drawn in the previous section.  As such, if the reader prefers, she might simply treat the Delaware and Illinois analyses as additional suggestive evidence corroborating findings from the other tests. 

An additional word of caution is warranted regarding the power of my tests.  In this paper, I do not find statistically significant evidence of deterrent effects—however, I cannot completely rule out the possibility of positive deterrent effects that are too small to measure.  Given that the average estimated deterrent effect in my primary specifications is negative (-0.03) and that the two most extreme results (New Mexico and Connecticut) indicate that abolishing the death penalty is associated with a _decrease_ in murder rates, the null result here does not appear to stem from a simple lack of statistical power.  Nevertheless, researchers would be well-advised to revisit this project in several years.  By that point, they should be able to add four new states—Colorado, New Hampshire, Virginia, and Washington—to this analysis, and will be able to add to the post-treatment period in the existing states.

A final point worth considering is the appropriate scope conditions for this project.  While the above analyses provide strong evidence that capital punishment statutes do not prevent murder by themselves, the results do not necessarily imply that frequent executions are devoid of deterrent capacity.  This qualification requires sustained attention.  The seven states under study here were fairly limited users of the death penalty—they combined for only 28 executions between 1995 and 2015, with the most recent execution in any state coming in Delaware in 2012.^[These statistics come from the Death Penalty Information Center, https://deathpenaltyinfo.org/executions/executions-overview/number-of-executions-by-state-and-region-since-1976.]  Only once did one of the seven states execute as many as five people in a single year.  Only Illinois executed nine or more people in any twenty-year period covered by this project, the minimum number Shepherd (2005) found necessary to trigger a deterrent effect.  

Figure 11 demonstrates this point graphically.  The majority of the states under study had not carried out an execution within five years of the death penalty's abolition; Delaware was the only state that was a relatively recent user of the punishment.  States like New Jersey and New York—which did not execute anyone in the period I consider—might even be considered de facto abolitionist states.  Certainly most of the states in this study would be considered "symbolic" death penalty states in the parlance of Steiker & Steiker (2016), rather than "executing states" (like Texas and Oklahoma).  As such, the conclusions drawn in this paper should not be uncritically applied to the Alabamas and Texases of the world.  The primary takeaway here should be that the de jure retention of the death penalty does not deter murder.

```{r, echo=FALSE, warning=FALSE, fig.width=14, fig.align="center", fig.height=8, out.width="7in"}

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))
plot(execution.data$Year[execution.data$State=="New York"], execution.data$Executions[execution.data$State=="New York"], main = "New York", ylim = c(0, 10))
abline(v=2004, col = "red")

plot(execution.data$Year[execution.data$State=="New Mexico"], execution.data$Executions[execution.data$State=="New Mexico"], main = "New Mexico", ylim = c(0, 10))
abline(v=2009, col = "red")
mtext("Figure 11: Executions By State and Year", side = 3, line = 4, font = 2)

plot(execution.data$Year[execution.data$State=="Illinois"], execution.data$Executions[execution.data$State=="Illinois"], main = "Illinois", ylim = c(0, 10))
abline(v=2011, col = "red")

plot(execution.data$Year[execution.data$State=="Connecticut"], execution.data$Executions[execution.data$State=="Connecticut"], main = "Connecticut", ylim = c(0, 10))
abline(v=2012, col = "red")

plot(execution.data$Year[execution.data$State=="New Jersey"], execution.data$Executions[execution.data$State=="New Jersey"], main = "New Jersey", ylim = c(0, 10))
abline(v=2007, col = "red")

plot(execution.data$Year[execution.data$State=="Delaware"], execution.data$Executions[execution.data$State=="Delaware"], main = "Delaware", ylim = c(0, 10))
abline(v=2016, col = "red")

plot(execution.data$Year[execution.data$State=="Maryland"], execution.data$Executions[execution.data$State=="Maryland"], main = "Maryland", ylim = c(0, 10))
abline(v=2013, col = "red")

```


Nevertheless, it would also be a mistake to understate the implications of my analyses.  First, consider again the case of Illinois.  Illinois is the one state in my sample that called a halted the death penalty after extensive recent use.  As mentioned above, Illinois imposed an execution moratorium in 2000, only a year after its last execution.  Indeed, in the five years immediately preceeding that moratorium, Illinois executed enough people to meet Shepherd's (2005) threshold for deterrence—the only state in my sample to do so. Thus, the Illinois moratorium provides an opportunity to consider whether halting the death penalty in the direct aftermath of a spate of executions leads to an increase in murder rates.

In order to take advantage of this development, I have re-run the analysis from Figure 1, but with the discontinuity set at the point of moratorium (2000), rather than at the date the legislature eliminated the death penalty.^[For the purposes of this analysis, I only use one year of the lagged dependent variable, 1995.]  Carrying out this test indicates that stopping executions did not lead to an increase in the logged murder rate—in the post-treatment period, the actual logged murder rate was typically less than the synthetic log murder rate (see Figure 12). 

```{r, echo=FALSE, warning=FALSE, fig.width=14, fig.align="center", fig.height=8, out.width="7in"}

par(oma = c(6,4,4,4), mar = c(4, 4, 4, 4), pch=20)
path.plot(synth.res = synth.out.3.1999, dataprep.res = Illinois.effect.1999, Ylab = "Log Murder Rate", Xlab = "Year", Legend = NA, Main = "Figure 12: Assessing the Impact of the 2000 Moratorium in Illinois", Ylim = c(0,5))
abline(v=2000, col = "red")
legend.cols <- c("black", "black", "red")
names(legend.cols) <- c("Treated", "Synthetic Control", "Year Moratorium Imposed")
par(fig= c(0, 1, 0, 1), oma = c(0,0,0,0), mar = c(.5, .5, .5, .5), new=TRUE)
plot(0,0, type = "n", bty="n", xaxt ="n", yaxt="n")
legend("bottomleft", text.width=c(0.3,0.3,0.3), legend=names(legend.cols), col = legend.cols, lty = c(1,2,1), lwd = c(2.5, 2.5, 2.5), cex = .75, xpd = TRUE, horiz = F, inset = c(0,0,0), bty = "y", text.font = 2)

```


Running the iterative placebo test for this "de facto" abolition supports this conclusion.  Table 10 provides the results of carrying out the iterative placebo test using (a) one lagged dependent variable; (b) no lagged dependent variables; and (c) the no border states specifications.  Across all of these specifications, the estimated deterrent effect is negative, and the p-values greater than 0.50.  These results suggests that my null findings above may not merely reflect the death penalty falling into disuse; it is possible that even reasonably consistent executions do not deter murders.  While I hasten to add that Illinois only provides a single data point—much more evidence would be needed to arrive at a definitive conclusion—it indicates the general lack of deterrence from executions is a plausible (though by no means confirmed) explanation for my findings.


```{r, include=F}

#### Illinois Placebo Prep
Illinois.placebos.defacto <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Illinois.defacto <- dataprep(foo = death.set, time.predictors.prior = c(1995:2000), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "illinois.lag.16"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2000), time.plot = c(1995:2017)) 
  synth.out.11 <- synth(data.prep.obj = death.set.effect.Illinois.defacto, method = "All")
  death.set.effect.Illinois.gaps.defacto <- death.set.effect.Illinois.defacto$Y1plot - (death.set.effect.Illinois.defacto$Y0plot %*% synth.out.11$solution.w);
  Illinois.placebos.defacto[,i] <- death.set.effect.Illinois.gaps.defacto
  i <- i + 1
}

final.Illinois.defacto <- cbind(Illinois.placebos.defacto, Illinois.gaps.defacto)
years <- seq(from=1995, to = 2018, by=1)

Illinois.pre.gaps.defacto <- final.Illinois.defacto[1:6,]
Illinois.post.gaps.defacto <- final.Illinois.defacto[7:nrow(final.Illinois.defacto),]

diff.in.diff.Illinois.defacto <- colMeans(Illinois.post.gaps.defacto) - colMeans(Illinois.pre.gaps.defacto)
diff.in.diff.Illinois.placebo.defacto <- diff.in.diff.Illinois.defacto[1:(length(diff.in.diff.Illinois.defacto)-1)]
diff.in.diff.Illinois.actual.defacto <- diff.in.diff.Illinois.defacto[length(diff.in.diff.Illinois.defacto)]

exceeds.Illinois.defacto<- length(diff.in.diff.Illinois.placebo.defacto[diff.in.diff.Illinois.placebo.defacto>diff.in.diff.Illinois.actual.defacto])  
less.than.Illinois.defacto <- length(diff.in.diff.Illinois.placebo.defacto)-exceeds.Illinois.defacto

container.matrix.defacto <- matrix(nrow = 3, ncol = 5)
container.matrix.defacto[1,] <- c("One Lagged DV", round(diff.in.diff.Illinois.actual.defacto, 2), exceeds.Illinois.defacto, less.than.Illinois.defacto, round((exceeds.Illinois.defacto/29), 2))

Illinois.effect.1999.2 <- dataprep(foo = Illinois.Set, time.predictors.prior = c(1995:2000), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 39, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2000), time.plot = c(1995:2017)) 


synth.out.3.1999.2 <- synth(data.prep.obj = Illinois.effect.1999.2, method = "All")

Illinois.tables.1999.2 <- synth.tab(dataprep.res = Illinois.effect.1999.2, synth.res = synth.out.3.1999.2)

Illinois.gaps.defacto.2 <- Illinois.effect.1999.2$Y1plot - (Illinois.effect.1999.2$Y0plot %*% synth.out.3.1999.2$solution.w)


Illinois.placebos.defacto.2 <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Illinois.defacto <- dataprep(foo = death.set, time.predictors.prior = c(1995:2000), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2000), time.plot = c(1995:2017)) 
  synth.out.11 <- synth(data.prep.obj = death.set.effect.Illinois.defacto, method = "All")
  death.set.effect.Illinois.gaps.defacto <- death.set.effect.Illinois.defacto$Y1plot - (death.set.effect.Illinois.defacto$Y0plot %*% synth.out.11$solution.w);
  Illinois.placebos.defacto.2[,i] <- death.set.effect.Illinois.gaps.defacto
  i <- i + 1
}

final.Illinois.defacto.2 <- cbind(Illinois.placebos.defacto.2, Illinois.gaps.defacto.2)
years <- seq(from=1995, to = 2018, by=1)

Illinois.pre.gaps.defacto.2 <- final.Illinois.defacto.2[1:6,]
Illinois.post.gaps.defacto.2 <- final.Illinois.defacto.2[7:nrow(final.Illinois.defacto.2),]

diff.in.diff.Illinois.defacto.2 <- colMeans(Illinois.post.gaps.defacto.2) - colMeans(Illinois.pre.gaps.defacto.2)
diff.in.diff.Illinois.placebo.defacto.2 <- diff.in.diff.Illinois.defacto.2[1:(length(diff.in.diff.Illinois.defacto.2)-1)]
diff.in.diff.Illinois.actual.defacto.2 <- diff.in.diff.Illinois.defacto.2[length(diff.in.diff.Illinois.defacto.2)]

exceeds.Illinois.defacto.2<- length(diff.in.diff.Illinois.placebo.defacto.2[diff.in.diff.Illinois.placebo.defacto.2>diff.in.diff.Illinois.actual.defacto.2])  
less.than.Illinois.defacto.2 <- length(diff.in.diff.Illinois.placebo.defacto.2)-exceeds.Illinois.defacto.2


container.matrix.defacto[2,] <- c("No Lagged DVs", round(diff.in.diff.Illinois.actual.defacto.2, 2), exceeds.Illinois.defacto.2, less.than.Illinois.defacto.2, round((exceeds.Illinois.defacto.2/29), 2))



Illinois.effect.nb.3 <- dataprep(foo = Illinois.Set.nb, time.predictors.prior = c(1995:2000), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "illinois.lag.1", "illinois.lag.8", "illinois.lag.16"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 39, controls.identifier = c(1:8,10,12,13,15:29), time.optimize.ssr = c(1995:2000), time.plot = c(1995:2017)) 


synth.out.3.1999.3 <- synth(data.prep.obj = Illinois.effect.nb.3, method = "All")

Illinois.tables.1999.3 <- synth.tab(dataprep.res = Illinois.effect.nb.3, synth.res = synth.out.3.1999.3)

Illinois.gaps.defacto.3 <- Illinois.effect.nb.3$Y1plot - (Illinois.effect.nb.3$Y0plot %*% synth.out.3.1999.3$solution.w)


Illinois.placebos.defacto.3 <- matrix(nrow = 23, ncol = 26)
i <- 1
for (s in c(1:8,10,12,13,15:29)) {
  controls <- c(1:8,10,12,13,15:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Illinois <- dataprep(foo = death.set.nb.3, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc", "illinois.lag.1", "illinois.lag.8", "illinois.lag.16"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 
  synth.out.11 <- synth(data.prep.obj = death.set.effect.Illinois, method = "All")
  death.set.effect.Illinois.gaps <- death.set.effect.Illinois$Y1plot - (death.set.effect.Illinois$Y0plot %*% synth.out.11$solution.w);
  Illinois.placebos.defacto.3[,i] <- death.set.effect.Illinois.gaps
  i <- i + 1
}

final.Illinois.defacto.3 <- cbind(Illinois.placebos.defacto.3, Illinois.gaps.defacto.3)
years <- seq(from=1995, to = 2018, by=1)

Illinois.pre.gaps.defacto.3 <- final.Illinois.defacto.3[1:6,]
Illinois.post.gaps.defacto.3 <- final.Illinois.defacto.3[7:nrow(final.Illinois.defacto.3),]

diff.in.diff.Illinois.defacto.3 <- colMeans(Illinois.post.gaps.defacto.3) - colMeans(Illinois.pre.gaps.defacto.3)
diff.in.diff.Illinois.placebo.defacto.3 <- diff.in.diff.Illinois.defacto.3[1:(length(diff.in.diff.Illinois.defacto.3)-1)]
diff.in.diff.Illinois.actual.defacto.3 <- diff.in.diff.Illinois.defacto.3[length(diff.in.diff.Illinois.defacto.3)]

exceeds.Illinois.defacto.3 <- length(diff.in.diff.Illinois.placebo.defacto.3[diff.in.diff.Illinois.placebo.defacto.3>diff.in.diff.Illinois.actual.defacto.3])  
less.than.Illinois.defacto.3 <- length(diff.in.diff.Illinois.placebo.defacto.3)-exceeds.Illinois.defacto.3

container.matrix.defacto[3,] <- c("No Bordering States", round(diff.in.diff.Illinois.actual.defacto.3, 2), exceeds.Illinois.defacto.3, less.than.Illinois.defacto.3, round((exceeds.Illinois.defacto.3/26), 2))


```

\singlespacing
\begin{longtable}{c>{\bfseries\centering\arraybackslash}p{2.5cm}>{\bfseries\centering\arraybackslash}p{2.5cm}>{\bfseries\centering\arraybackslash}p{2.5cm}>{\bfseries\centering\arraybackslash}p{2.5cm}}
\toprule
\multicolumn{5}{c}{\bgroup\fontsize{12}{14}\selectfont \textbf{Table 10: Permutation Tests of Effect Size, Illinois De Facto Abolition}\egroup{}} \\
\cmidrule(l{3pt}r{3pt}){1-5}
\textbf{Specification} & \textbf{Estimated Deterrence Effect} & \textbf{Placebos With Larger Deterrence Effects} & \textbf{Placebos With Smaller Deterrence Effects} & \textbf{Proportion of Placebos With Larger Deterrence Effect}\\
\midrule
\endfirsthead
\multicolumn{5}{@{}l}{\textit{(continued)}}\\
\toprule
\textbf{Specification} & \textbf{Estimated Deterrence Effect} & \textbf{Placebos With Larger Deterrence Effects} & \textbf{Placebos With Smaller Deterrence Effects} & \textbf{Proportion of Placebos With Larger Deterrence Effect}\\
\midrule
\endhead
\
\endfoot
\bottomrule
\endlastfoot
One Lagged DV & -0.06 & 16 & 13 & 0.55\\
No Lagged DVs & -0.02 & 15 & 14 & 0.52\\
No Bordering States & -0.05 & 17 & 9 & 0.65\\*
\end{longtable}
\doublespacing

Second, most states with the death penalty use it sparingly.  The punishment remains legal in 27 states, but only 12 have executed enough people over the last twenty years to hit the deterrence threshold proposed by Shepherd.  Ten states have executed fewer than five people during that span, while Oregon, Pennsylvania, and Wyoming have not put anyone to death since 2000.  In short, most death penalty states are in precisely the position of the jurisdictions under study here—light users of the punishment that, according to the above results, do not obtain any measurable deterrence from their capital punishment statutes.  If such states reconsider their use of capital punishment at some point in the future, they still might choose to retain it for reasons of retribution or incapacitation.  They would be mistaken, however, if they continued to base their support for the penalty on its capacity to prevent murder.

\newpage 

\clearpage
\pagenumbering{arabic} 

\noindent\textbf{Appendix A: Data Sources}

In compiling the data necessary to carry out this project, I drew extensively on information available through various government agencies and non-profits.  First, I relied on the Death Penalty Information Center for murder rates by state and year.  For crime rate statistics, I used the FBI’s Uniform Crime Reporting Service; for yearly unemployment rates, I exploit data drawn from the Bureau of Labor Statistics.  The U.S. Census Bureau provided population density data, as well as poverty rate data.  For state-level estimates of the 15-29 year-old population, I extracted data from the Center For Disease Control’s “WONDER” database.  I obtained estimates of real GDP per capita from the Bureau of Economic Analysis, and the percentage of income held by the top 1% of earners from Estelle Sommeiller and Mark Price’s report for the Economic Policy Institute, titled “The New Gilded Age.”  Finally, I relied on the Urban Institute for data on direct state police expenditures.

\newpage

\noindent\textbf{Appendix B: Intimate Homicide Rate and Acquaintance Homicide Rate as the Dependent Variable}

In this Appendix, I test the effects of death penalty abolition on homicides by intimates and acquaintances.  Just as in the body of the paper, I used the FBI’s Supplementary Homicide Reports as aggregated by Kaplan (2020) to calculate homicide rates for these murder subtypes.  I used the same procedure discussed in footnote 14 to extract "imtimate homicides per 100,000" and "acquaintance homicides per 100,000."  

Unlike homicides by strangers, the Supplementary Homicide Reports keep fine-grained data on the precise nature of the relationship between the victim and perpetrator in the case of homicides by intimates and acquaintances.  This categorization system required me to make judgement calls about which labels denoted a homicide by an "intimate" and which labels denoted a homicide by an "acquaintance." In the interest of transparency, I sorted the Supplementary Homicide Reports' (sometimes inartful) categories into the two broader classes as follows:

\noindent Intimates: "boyfriend"; "brother"; "common-law husband"; "common-law wife";  "daughter"; "ex-husband"; "ex-wife"; "father"; "girlfriend"; "homosexual relationship"; "husband"; "in-law"; "mother"; "other family"; "sister"; "son"; "stepdaughter"; "stepfather"; "stepmother"; "stepson"; and "wife."  

\noindent Acquaintances: "acquaintance"; "employee"; "employer"; "friend"; "neighbor"; and "other - known to victim." 

Due to missing state-years, I was only able to use 24 of the 29 states in the original dataset to construct synthetic controls for these analyses.  The fits these synthetic controls provide are not as tight as those in the main text, but they are sufficient for the purposes of a robustness check.  

Tables A.1 and A.2 present the result of placebo tests using "acquaintance homicide rate" and "intimate homicide rate" as the dependent variable.  They largely resemble the results presented in the main paper.  The majority of the deterrent effects are not in the expected direction. Only for one of the fourteen analyses—intimate homicides in Delaware—are a statistically significant proportion of the placebo deterrent effects estimates less than the actual estimate.  
'
\singlespacing
\begin{longtable}{c>{\bfseries\centering\arraybackslash}p{2.5cm}>{\bfseries\centering\arraybackslash}p{2.5cm}>{\bfseries\centering\arraybackslash}p{2.5cm}>{\bfseries\centering\arraybackslash}p{2.5cm}}
\toprule
\multicolumn{5}{c}{\bgroup\fontsize{12}{14}\selectfont \textbf{Table A.1: Permutation Tests of Effect Size, Acquaintance Homicides}\egroup{}} \\
\cmidrule(l{3pt}r{3pt}){1-5}
\textbf{State} & \textbf{Estimated Deterrence Effect} & \textbf{Placebos With Larger Deterrence Effects} & \textbf{Placebos With Smaller Deterrence Effects} & \textbf{Proportion of Placebos With Larger Deterrence Effect}\\
\midrule
\endfirsthead
\multicolumn{5}{@{}l}{\textit{(continued)}}\\
\toprule
\textbf{State} & \textbf{Estimated Deterrence Effect} & \textbf{Placebos With Larger Deterrence Effects} & \textbf{Placebos With Smaller Deterrence Effects} & \textbf{Proportion of Placebos With Larger Deterrence Effect}\\
\midrule
\endhead
\
\endfoot
\bottomrule
\endlastfoot
New York & 0.13 & 8 & 16 & 0.38\\
New Mexico & 0.26 & 4 & 20 & 0.19\\
Illinois & -0.05 & 13 & 11 & 0.62\\
Connecticut & -0.43 & 21 & 3 & 1\\
New Jersey & -0.23 & 17 & 7 & 0.81\\
\addlinespace
Delaware & 0.07 & 8 & 16 & 0.38\\
Maryland & -0.19 & 17 & 7 & 0.81\\*
\end{longtable}
\doublespacing


\singlespacing
\begin{longtable}{c>{\bfseries\centering\arraybackslash}p{2.5cm}>{\bfseries\centering\arraybackslash}p{2.5cm}>{\bfseries\centering\arraybackslash}p{2.5cm}>{\bfseries\centering\arraybackslash}p{2.5cm}}
\toprule
\multicolumn{5}{c}{\bgroup\fontsize{12}{14}\selectfont \textbf{Table A.2: Permutation Tests of Effect Size, Intimate Homicides}\egroup{}} \\
\cmidrule(l{3pt}r{3pt}){1-5}
\textbf{State} & \textbf{Estimated Deterrence Effect} & \textbf{Placebos With Larger Deterrence Effects} & \textbf{Placebos With Smaller Deterrence Effects} & \textbf{Proportion of Placebos With Larger Deterrence Effect}\\
\midrule
\endfirsthead
\multicolumn{5}{@{}l}{\textit{(continued)}}\\
\toprule
\textbf{State} & \textbf{Estimated Deterrence Effect} & \textbf{Placebos With Larger Deterrence Effects} & \textbf{Placebos With Smaller Deterrence Effects} & \textbf{Proportion of Placebos With Larger Deterrence Effect}\\
\midrule
\endhead
\
\endfoot
\bottomrule
\endlastfoot
New York & -0.02 & 9 & 15 & 0.43\\
New Mexico & 0.07 & 5 & 19 & 0.24\\
Illinois & -0.09 & 18 & 6 & 0.86\\
Connecticut & -0.13 & 20 & 4 & 0.95\\
New Jersey & -0.09 & 18 & 6 & 0.86\\
\addlinespace
Delaware & 0.4 & 1 & 23 & 0.05\\
Maryland & 0.11 & 8 & 16 & 0.38\\*
\end{longtable}
\doublespacing

However, even this finding may not represent an real deterrent effect.  As Figure A.1 illustrates, the fit between the true intimate homicide rate and the synthetic control is quite poor for Delaware.  Moreover, my analysis only contains two years of data from after Delaware's 2016 elimination of the death penalty, which, as mentioned above, may not be a long enough period to accurately measure a deterrent effect.  Viewed in light of the other findings presented in this paper, it seems plausible that the Delaware result is a product of noisy data, rather than a genuine causal effect.

```{r, echo=FALSE, warning=FALSE, fig.width=14, fig.align="center", fig.height=8, out.width="7in"}

par(oma = c(6,4,4,4), mar = c(4, 4, 4, 4), pch=20)
path.plot(synth.res = synth.out.6.intimate, dataprep.res = Delaware.effect.intimate, Ylab = "Intimate Homicide Rate", Xlab = "Year", Legend = NA, Main = "Figure A.1: Synthetic Control Plot for Delaware (y = Intimate Murders Per 100,000 Residents", Ylim = c(0,5))
abline(v=2016, col = "red")
legend.cols <- c("black", "black", "red")
names(legend.cols) <- c("Treated", "Synthetic Control", "Year Eliminated DP")
par(fig= c(0, 1, 0, 1), oma = c(0,0,0,0), mar = c(.5, .5, .5, .5), new=TRUE)
plot(0,0, type = "n", bty="n", xaxt ="n", yaxt="n")
legend("bottom", text.width=c(0.3,0.3,0.3), legend=names(legend.cols), col = legend.cols, lty = c(1,2,1), lwd = c(2.5, 2.5, 2.5), cex = .75, xpd = TRUE, horiz = F, inset = c(0,0,0), bty = "y", text.font = 2)

```

\newpage

\noindent\textbf{Appendix C: RMSPE Calculations for Different Lagged Dependent Variable Choices}

This Appendix contains root mean squared error (RMSPE) calcuations for each of the four lagged dependent variable specifications I tested for my main analyses.  Table A.3 presents the pre-treatment period RMSPE—that is, the square root of the mean squared difference between the dependent variable values for the synthetic control and actual data—for each state given each specification.  In the final column of the table, I sum the RMSPEs of the individual states for that model.

```{r, include=F}
ny.pre.treatment.gaps <- ny.gaps[1:10,]

nm.pre.treatment.gaps <- nm.gaps[1:15,]

Illinois.pre.treatment.gaps <- Illinois.gaps[1:17,]

Conn.pre.treatment.gaps <- Conn.gaps[1:18,]

NJ.pre.treatment.gaps <- NJ.gaps[1:13,]

Delaware.pre.treatment.gaps <- Delaware.gaps[1:22,]

Maryland.pre.treatment.gaps <- Maryland.gaps[1:19,]


sum.mse <- sqrt(mean(ny.pre.treatment.gaps^2)) + sqrt(mean(nm.pre.treatment.gaps^2)) + sqrt(mean(Illinois.pre.treatment.gaps^2)) + sqrt(mean(Conn.pre.treatment.gaps^2)) + sqrt(mean(NJ.pre.treatment.gaps^2)) + sqrt(mean(Delaware.pre.treatment.gaps^2)) + sqrt(mean(Maryland.pre.treatment.gaps^2))

ny.pre.treatment.gaps.robust.2 <- ny.gaps.robust.2[1:10,]

nm.pre.treatment.gaps.robust.2 <- nm.gaps.robust.2[1:15,]

Illinois.pre.treatment.gaps.robust.2 <- Illinois.gaps.robust.2[1:17,]

Conn.pre.treatment.gaps.robust.2 <- Conn.gaps.robust.2[1:18,]

NJ.pre.treatment.gaps.robust.2 <- NJ.gaps.robust.2[1:13,]

Delaware.pre.treatment.gaps.robust.2 <- Delaware.gaps.robust.2[1:22,]

Maryland.pre.treatment.gaps.robust.2 <- Maryland.gaps.robust.2[1:19,]


sum.mse.robust.2 <- sqrt(mean(ny.pre.treatment.gaps.robust.2^2)) + sqrt(mean(nm.pre.treatment.gaps.robust.2^2)) + sqrt(mean(Illinois.pre.treatment.gaps.robust.2^2)) + sqrt(mean(Conn.pre.treatment.gaps.robust.2^2)) + sqrt(mean(NJ.pre.treatment.gaps.robust.2^2)) + sqrt(mean(Delaware.pre.treatment.gaps.robust.2^2)) + sqrt(mean(Maryland.pre.treatment.gaps.robust.2^2))


ny.pre.treatment.gaps.robust.3 <- ny.gaps.robust.3[1:10,]

nm.pre.treatment.gaps.robust.3 <- nm.gaps.robust.3[1:15,]

Illinois.pre.treatment.gaps.robust.3 <- Illinois.gaps.robust.3[1:17,]

Conn.pre.treatment.gaps.robust.3 <- Conn.gaps.robust.3[1:18,]

NJ.pre.treatment.gaps.robust.3 <- NJ.gaps.robust.3[1:13,]

Delaware.pre.treatment.gaps.robust.3 <- Delaware.gaps.robust.3[1:22,]

Maryland.pre.treatment.gaps.robust.3 <- Maryland.gaps.robust.3[1:19,]


sum.mse.robust.3 <- sqrt(mean(ny.pre.treatment.gaps.robust.3^2)) + sqrt(mean(nm.pre.treatment.gaps.robust.3^2)) + sqrt(mean(Illinois.pre.treatment.gaps.robust.3^2)) + sqrt(mean(Conn.pre.treatment.gaps.robust.3^2)) + sqrt(mean(NJ.pre.treatment.gaps.robust.3^2)) + sqrt(mean(Delaware.pre.treatment.gaps.robust.3^2)) + sqrt(mean(Maryland.pre.treatment.gaps.robust.3^2))

ny.pre.treatment.gaps.robust.4 <- ny.gaps.robust.4[1:10,]

nm.pre.treatment.gaps.robust.4 <- nm.gaps.robust.4[1:15,]

Illinois.pre.treatment.gaps.robust.4 <- Illinois.gaps.robust.4[1:17,]

Conn.pre.treatment.gaps.robust.4 <- Conn.gaps.robust.4[1:18,]

NJ.pre.treatment.gaps.robust.4 <- NJ.gaps.robust.4[1:13,]

Delaware.pre.treatment.gaps.robust.4 <- Delaware.gaps.robust.4[1:22,]

Maryland.pre.treatment.gaps.robust.4 <- Maryland.gaps.robust.4[1:19,]


sum.mse.robust.4 <- sqrt(mean(ny.pre.treatment.gaps.robust.4^2)) + sqrt(mean(nm.pre.treatment.gaps.robust.4^2)) + sqrt(mean(Illinois.pre.treatment.gaps.robust.4^2)) + sqrt(mean(Conn.pre.treatment.gaps.robust.4^2)) + sqrt(mean(NJ.pre.treatment.gaps.robust.4^2)) + sqrt(mean(Delaware.pre.treatment.gaps.robust.4^2)) + sqrt(mean(Maryland.pre.treatment.gaps.robust.4^2))

container.matrix.mse <- matrix(nrow = 4, ncol = 9)

container.matrix.mse[1,] <- c("Three Lagged Dependent Variable Years As Predictors", round(sqrt(mean(ny.pre.treatment.gaps^2)), 3), round(sqrt(mean(nm.pre.treatment.gaps^2)), 3), round(sqrt(mean(Illinois.pre.treatment.gaps^2)), 3), round(sqrt(mean(Conn.pre.treatment.gaps^2)), 3), round(sqrt(mean(NJ.pre.treatment.gaps^2)), 3), round(sqrt(mean(Delaware.pre.treatment.gaps^2)), 3), round(sqrt(mean(Maryland.pre.treatment.gaps^2)), 3), round(sum.mse, 3))

container.matrix.mse[2,] <- c("No Lagged Dependent Variable Years as Predictors", round(sqrt(mean(ny.pre.treatment.gaps.robust.2^2)), 3), round(sqrt(mean(nm.pre.treatment.gaps.robust.2^2)), 3), round(sqrt(mean(Illinois.pre.treatment.gaps.robust.2^2)), 3), round(sqrt(mean(Conn.pre.treatment.gaps.robust.2^2)), 3), round(sqrt(mean(NJ.pre.treatment.gaps.robust.2^2)), 3), round(sqrt(mean(Delaware.pre.treatment.gaps.robust.2^2)), 3), round(sqrt(mean(Maryland.pre.treatment.gaps.robust.2^2)), 3), round(sum.mse.robust.2, 3))

container.matrix.mse[3,] <- c("Mean Pre-Period Dependent Variable as Predictor", round(sqrt(mean(ny.pre.treatment.gaps.robust.3^2)), 3), round(sqrt(mean(nm.pre.treatment.gaps.robust.3^2)), 3), round(sqrt(mean(Illinois.pre.treatment.gaps.robust.3^2)), 3), round(sqrt(mean(Conn.pre.treatment.gaps.robust.3^2)), 3), round(sqrt(mean(NJ.pre.treatment.gaps.robust.3^2)), 3), round(sqrt(mean(Delaware.pre.treatment.gaps.robust.3^2)), 3), round(sqrt(mean(Maryland.pre.treatment.gaps.robust.3^2)), 3), round(sum.mse.robust.3, 3))

container.matrix.mse[4,] <- c("Dependent Vairable Value in Last Pre-Abolition Year as Predictor", round(sqrt(mean(ny.pre.treatment.gaps.robust.4^2)), 3), round(sqrt(mean(nm.pre.treatment.gaps.robust.4^2)), 3), round(sqrt(mean(Illinois.pre.treatment.gaps.robust.4^2)), 3), round(sqrt(mean(Conn.pre.treatment.gaps.robust.4^2)), 3), round(sqrt(mean(NJ.pre.treatment.gaps.robust.4^2)), 3), round(sqrt(mean(Delaware.pre.treatment.gaps.robust.4^2)), 3), round(sqrt(mean(Maryland.pre.treatment.gaps.robust.4^2)), 3), round(sum.mse.robust.4, 3))

```

\singlespacing
\begin{longtable}{>{\centering\arraybackslash}p{2.5cm}>{\bfseries\centering\arraybackslash}p{1.5cm}>{\bfseries\centering\arraybackslash}p{1.5cm}>{\bfseries\centering\arraybackslash}p{1.5cm}>{\bfseries\centering\arraybackslash}p{1.5cm}>{\bfseries\centering\arraybackslash}p{1.5cm}>{\bfseries\centering\arraybackslash}p{1.5cm}>{\bfseries\centering\arraybackslash}p{1.5cm}>{\bfseries\centering\arraybackslash}p{2cm}}
\toprule
\multicolumn{9}{c}{\bgroup\fontsize{12}{14}\selectfont \textbf{Table A.3: Root Mean Square Prediction Error Calculations}\egroup{}} \\
\cmidrule(l{3pt}r{3pt}){1-9}
\begingroup\fontsize{6}{8}\selectfont \textbf{Specification}\endgroup & \begingroup\fontsize{6}{8}\selectfont \textbf{New York RMSPE}\endgroup & \begingroup\fontsize{6}{8}\selectfont \textbf{New Mexico RMSPE}\endgroup & \begingroup\fontsize{6}{8}\selectfont \textbf{Illinois RMSPE}\endgroup & \begingroup\fontsize{6}{8}\selectfont \textbf{Connecticut RMSPE}\endgroup & \begingroup\fontsize{6}{8}\selectfont \textbf{New Jersey RMSPE}\endgroup & \begingroup\fontsize{6}{8}\selectfont \textbf{Delaware RMSPE}\endgroup & \begingroup\fontsize{6}{8}\selectfont \textbf{Maryland RMSPE}\endgroup & \begingroup\fontsize{6}{8}\selectfont \textbf{Total Specification RMSPE}\endgroup\\
\midrule
\endfirsthead
\multicolumn{9}{@{}l}{\textit{(continued)}}\\
\toprule
\begingroup\fontsize{6}{8}\selectfont \textbf{Specification}\endgroup & \begingroup\fontsize{6}{8}\selectfont \textbf{New York RMSPE}\endgroup & \begingroup\fontsize{6}{8}\selectfont \textbf{New Mexico RMSPE}\endgroup & \begingroup\fontsize{6}{8}\selectfont \textbf{Illinois RMSPE}\endgroup & \begingroup\fontsize{6}{8}\selectfont \textbf{Connecticut RMSPE}\endgroup & \begingroup\fontsize{6}{8}\selectfont \textbf{New Jersey RMSPE}\endgroup & \begingroup\fontsize{6}{8}\selectfont \textbf{Delaware RMSPE}\endgroup & \begingroup\fontsize{6}{8}\selectfont \textbf{Maryland RMSPE}\endgroup & \begingroup\fontsize{6}{8}\selectfont \textbf{Total Specification RMSPE}\endgroup\\
\midrule
\endhead
\
\endfoot
\bottomrule
\endlastfoot
\begingroup\fontsize{6}{8}\selectfont Three Lagged Dependent Variable Years As Predictors\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.046\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.176\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.082\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.127\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.058\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.176\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.067\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.731\endgroup\\
\hline
\begingroup\fontsize{6}{8}\selectfont No Lagged Dependent Variable Years as Predictors\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.119\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.182\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.113\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.127\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.074\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.363\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.196\endgroup & \begingroup\fontsize{6}{8}\selectfont 1.174\endgroup\\
\hline
\begingroup\fontsize{6}{8}\selectfont Mean Pre-Period Dependent Variable as Predictor\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.046\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.182\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.098\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.125\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.056\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.29\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.067\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.864\endgroup\\
\hline
\begingroup\fontsize{6}{8}\selectfont Dependent Vairable Value in Last Pre-Abolition Year as Predictor\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.046\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.182\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.098\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.127\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.075\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.386\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.072\endgroup & \begingroup\fontsize{6}{8}\selectfont 0.985\endgroup\\*
\end{longtable}
\doublespacing

As mentioned above, the main specification I deploy (using three lagged dependent variable values as predictors) substantially outperforms the others.  Unsurprisingly, the model that does not use any lagged dependent variable values as predictors fares the worst, with the other alternative strategies falling somewhere in-between.  The largest gains from using the first specification seem to come from the improved fit in Delaware; in all other models, the synthetic control for Delaware is a poor approximation of the log murder rates.  

\newpage

\noindent\textbf{Appendix D: Panel Difference-in-Differences Model}

This Appendix provides the panel data analysis discussed in Section 2.  In calculating this model, I use all of the predictors used to construct my initial set of synthetic controls, with the exception of the lagged dependent variables (which I omit).  The model covers a twenty-one-year period (1995-2015) and includes the 37 states I use to run the synthetic control analyses.  The purpose this model serves is to motivate my use of the synthetic control methodology—I do not draw any substantive conclusions from the results.

\begin{table}[!htbp] \centering 
\tiny
  \caption*{Table A.4: Panel Difference-in-Differences Model} 
  \label{} 
\begin{tabular}{@{\extracolsep{-5pt}}lc} 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
\\[-1.8ex] & Logged Murder Rate \\ 
\hline \\[-1.8ex] 
 Death Penalty Statute (1 = Yes, 0 = No) & 0.055 \\ 
  & (0.044) \\ 
  & \\ 
 Property Crime Rate (Crimes Per Resident) & 5.686$^{*}$ \\ 
  & (3.089) \\ 
  & \\ 
 Unemployment Rate (Percentage) & $-$0.030$^{**}$ \\ 
  & (0.013) \\ 
  & \\ 
 Robberies Per Resident & 205.319$^{***}$ \\ 
  & (52.074) \\ 
  & \\ 
 Population Density & 0.004$^{**}$ \\ 
  & (0.002) \\ 
  & \\ 
 Proportion 15-29 & 2.166 \\ 
  & (2.023) \\ 
  & \\ 
 GDP Per Capita (2012 Dollars) & $-$0.00000 \\ 
  & (0.00001) \\ 
  & \\ 
 Percentage of Income Held By Top 1 Percent & $-$0.001 \\ 
  & (0.004) \\ 
  & \\ 
 Percentage in Poverty & $-$0.005 \\ 
  & (0.005) \\ 
  & \\ 
 Direct Expenditures on Police Per Capita & 0.001 \\ 
  & (0.002) \\ 
  & \\ 
State Fixed Effects & Yes \\ 
Year Fixed Effects & Yes \\ 
Standard Errors Clustered By Unit & Yes \\ 
\textit{N} & 756 \\ 
R$^{2}$ & 0.909 \\ 
\hline 
\hline \\[-1.8ex] 
\textit{Notes:} & \multicolumn{1}{l}{$^{***}$Significant at the 1 percent level.} \\ 
 & \multicolumn{1}{l}{$^{**}$Significant at the 5 percent level.} \\ 
 & \multicolumn{1}{l}{$^{*}$Significant at the 10 percent level.} \\ 
\end{tabular} 
\end{table} 

\newpage

\noindent\textbf{Appendix E: Additional Robustness Checks for the No Lagged Dependent Variable Model}

In this Appendix, I provide robustness checks for the first analysis in Table 5 (which omits lagged outcome variables from the set of predictors).  These models are somewhat less reliable than my primary specification—removing lagged dependent variables from the set of predictors limits the robustness of the synthetic control method by compromising its ability to account for time-varying confounders and increasing pre-period RMSPE.  However, those interested in how the lagged outcome variables affect my results may find these analyses useful.  

Table A.5 re-runs the placebo tests from Tables 9 and 6, while Figures A.2 and A.3 test those same specifications using the type of placebo test conducted in Figure 4.  The results largely resemble those in the body of the article.  For Illinois, the p-values are relatively low in Table A.5 (though not significant at the p < .05 level)—however, those low p-values increase when conducting the RMSPE ratio tests (see Figures A.2 and A.3).  Ultimately, these analyses largely affirm the results in the main text. It is worth reiterating, though, that they have limited probative value because of their deviation from best practices when using synthetic controls (see, e.g., Kaul 2016).  

```{r, include=F}

new.york.effect.diff.vars.no.lag <- dataprep(foo = NY.Set, time.predictors.prior = c(1995:2004), predictors = c("prison.rate.n", "Unemployment.Rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "officer_rate_per_1000"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 36, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 

synth.out.diff.vars.no.lag <- synth(data.prep.obj = new.york.effect.diff.vars.no.lag, method = "All")

ny.tables.diff.vars.no.lag <- synth.tab(dataprep.res = new.york.effect.diff.vars.no.lag, synth.res = synth.out.diff.vars.no.lag)

path.plot(synth.res = synth.out.diff.vars.no.lag, dataprep.res = new.york.effect.diff.vars.no.lag, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004)

ny.gaps.diff.vars.no.lag <- new.york.effect.diff.vars.no.lag$Y1plot - (new.york.effect.diff.vars.no.lag$Y0plot %*% synth.out.diff.vars.no.lag$solution.w)


### New Mexico

nm.effect.diff.vars.no.lag <- dataprep(foo = NM.Set, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "prison.rate.n", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "officer_rate_per_1000"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 40, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 

synth.out.2.diff.vars.no.lag <- synth(data.prep.obj = nm.effect.diff.vars.no.lag, method = "All")

nm.tables.diff.vars.no.lag <- synth.tab(dataprep.res = nm.effect.diff.vars.no.lag, synth.res = synth.out.2.diff.vars.no.lag)


path.plot(synth.res = synth.out.2.diff.vars.no.lag, dataprep.res = nm.effect.diff.vars.no.lag, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009)

nm.gaps.diff.vars.no.lag <- nm.effect.diff.vars.no.lag$Y1plot - (nm.effect.diff.vars.no.lag$Y0plot %*% synth.out.2.diff.vars.no.lag$solution.w)


### Illinois 

Illinois.effect.diff.vars.no.lag <- dataprep(foo = Illinois.Set, time.predictors.prior = c(1995:2011), predictors = c("prison.rate.n", "Unemployment.Rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "officer_rate_per_1000"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 39, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 

synth.out.3.diff.vars.no.lag <- synth(data.prep.obj = Illinois.effect.diff.vars.no.lag, method = "All")

Illinois.tables.diff.vars.no.lag <- synth.tab(dataprep.res = Illinois.effect.diff.vars.no.lag, synth.res = synth.out.3.diff.vars.no.lag)

path.plot(synth.res = synth.out.3.diff.vars.no.lag, dataprep.res = Illinois.effect.diff.vars.no.lag, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011)

Illinois.gaps.diff.vars.no.lag <- Illinois.effect.diff.vars.no.lag$Y1plot - (Illinois.effect.diff.vars.no.lag$Y0plot %*% synth.out.3.diff.vars.no.lag$solution.w)


### Connecticut

Conn.effect.diff.vars.no.lag <- dataprep(foo = Conn.Set, time.predictors.prior = c(1995:2012), predictors = c("prison.rate.n", "Unemployment.Rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "officer_rate_per_1000"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 41, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 

synth.out.4.diff.vars.no.lag <- synth(data.prep.obj = Conn.effect.diff.vars.no.lag, method = "All")

Conn.tables.diff.vars.no.lag <- synth.tab(dataprep.res = Conn.effect.diff.vars.no.lag, synth.res = synth.out.4.diff.vars.no.lag)

path.plot(synth.res = synth.out.4.diff.vars.no.lag, dataprep.res = Conn.effect.diff.vars.no.lag, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012)

Conn.gaps.diff.vars.no.lag <- Conn.effect.diff.vars.no.lag$Y1plot - (Conn.effect.diff.vars.no.lag$Y0plot %*% synth.out.4.diff.vars.no.lag$solution.w)


### New Jersey

NJ.effect.diff.vars.no.lag <- dataprep(foo = NJ.Set, time.predictors.prior = c(1995:2007), predictors = c("prison.rate.n", "Unemployment.Rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "officer_rate_per_1000"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 42, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 

synth.out.5.diff.vars.no.lag <- synth(data.prep.obj = NJ.effect.diff.vars.no.lag, method = "All")

NJ.tables.diff.vars.no.lag <- synth.tab(dataprep.res = NJ.effect.diff.vars.no.lag, synth.res = synth.out.5.diff.vars.no.lag)

path.plot(synth.res = synth.out.5.diff.vars.no.lag, dataprep.res = NJ.effect.diff.vars.no.lag, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007)

NJ.gaps.diff.vars.no.lag <- NJ.effect.diff.vars.no.lag$Y1plot - (NJ.effect.diff.vars.no.lag$Y0plot %*% synth.out.5.diff.vars.no.lag$solution.w)

### Delaware

Delaware.effect.diff.vars.no.lag <- dataprep(foo = Delaware.Set, time.predictors.prior = c(1995:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "officer_rate_per_1000"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 38, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2016), time.plot = c(1995:2018)) 

synth.out.6.diff.vars.no.lag <- synth(data.prep.obj = Delaware.effect.diff.vars.no.lag, method = "All")

Delaware.tables.diff.vars.no.lag <- synth.tab(dataprep.res = Delaware.effect.diff.vars.no.lag, synth.res = synth.out.6.diff.vars.no.lag)


path.plot(synth.res = synth.out.6.diff.vars.no.lag, dataprep.res = Delaware.effect.diff.vars.no.lag, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016)

Delaware.gaps.diff.vars.no.lag <- Delaware.effect.diff.vars.no.lag$Y1plot - (Delaware.effect.diff.vars.no.lag$Y0plot %*% synth.out.6.diff.vars.no.lag$solution.w)

### Maryland

Maryland.effect.diff.vars.no.lag <- dataprep(foo = Maryland.Set, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "officer_rate_per_1000"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 37, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 

synth.out.7.diff.vars.no.lag <- synth(data.prep.obj = Maryland.effect.diff.vars.no.lag, method = "All")

path.plot(synth.res = synth.out.7.diff.vars.no.lag, dataprep.res = Maryland.effect.diff.vars.no.lag, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013)

Maryland.tables.diff.vars.no.lag <- synth.tab(dataprep.res = Maryland.effect.diff.vars.no.lag, synth.res = synth.out.7.diff.vars.no.lag)

Maryland.gaps.diff.vars.no.lag <- Maryland.effect.diff.vars.no.lag$Y1plot - (Maryland.effect.diff.vars.no.lag$Y0plot %*% synth.out.7.diff.vars.no.lag$solution.w)



############### ############### ############### 
############### Single Plot ###############
############### ############### ############### 



### New York 

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))
path.plot(synth.res = synth.out.diff.vars.no.lag, dataprep.res = new.york.effect.diff.vars.no.lag, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004, col = "red")

### New Mexico


path.plot(synth.res = synth.out.2.diff.vars.no.lag, dataprep.res = nm.effect.diff.vars.no.lag, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009, col = "red")
mtext("Figure X: Synthetic Control Plots With Alternative Predictors (y = Log Murders Per 100,000 Residents)", side = 3, line = 4, font = 2)

### Illinois 


path.plot(synth.res = synth.out.3.diff.vars.no.lag, dataprep.res = Illinois.effect.diff.vars.no.lag, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011, col = "red")



### Connecticut


path.plot(synth.res = synth.out.4.diff.vars.no.lag, dataprep.res = Conn.effect.diff.vars.no.lag, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012, col = "red")


### New Jersey


path.plot(synth.res = synth.out.5.diff.vars.no.lag, dataprep.res = NJ.effect.diff.vars.no.lag, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007, col = "red")


### Delaware


path.plot(synth.res = synth.out.6.diff.vars.no.lag, dataprep.res = Delaware.effect.diff.vars.no.lag, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016, col = "red")


### Maryland

path.plot(synth.res = synth.out.7.diff.vars.no.lag, dataprep.res = Maryland.effect.diff.vars.no.lag, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013, col = "red")

legend.cols <- c("black", "black", "red")
names(legend.cols) <- c("Treated", "Synthetic Control", "Year Eliminated DP")
par(fig= c(0, 1, 0, 1), oma = c(0,0,0,0), mar = c(.5, .5, .5, .5), new=TRUE)
plot(0,0, type = "n", bty="n", xaxt ="n", yaxt="n")
legend("bottom", text.width=c(0.3,0.3,0.3), legend=names(legend.cols), col = legend.cols, lty = c(1,2,1), lwd = c(2.5, 2.5, 2.5), cex = .75, xpd = TRUE, horiz = F, inset = c(0,0,0), bty = "y", text.font = 2)


########################################
###### Adding to Placebo Gap Analysis ############
########################################

#### NY Placebo Prep
ny.placebos.diff.vars.no.lag <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.ny <- dataprep(foo = death.set, time.predictors.prior = c(1995:2004), predictors = c("prison.rate.n", "Unemployment.Rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "officer_rate_per_1000"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 
  synth.out.9 <- synth(data.prep.obj = death.set.effect.ny, method = "All")
  death.set.effect.ny.gaps <- death.set.effect.ny$Y1plot - (death.set.effect.ny$Y0plot %*% synth.out.9$solution.w);
  ny.placebos.diff.vars.no.lag[,i] <- death.set.effect.ny.gaps
  i <- i + 1
}

final.ny.diff.vars.no.lag <- cbind(ny.placebos.diff.vars.no.lag, ny.gaps.diff.vars.no.lag)
years <- seq(from=1995, to = 2018, by=1)

#### NM Placebo Prep
NM.placebos.diff.vars.no.lag <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NM <- dataprep(foo = death.set, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "prison.rate.n", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "officer_rate_per_1000"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 
  synth.out.10 <- synth(data.prep.obj = death.set.effect.NM, method = "All")
  death.set.effect.nm.gaps <- death.set.effect.NM$Y1plot - (death.set.effect.NM$Y0plot %*% synth.out.10$solution.w);
  NM.placebos.diff.vars.no.lag[,i] <- death.set.effect.nm.gaps
  i <- i + 1
}

final.NM.diff.vars.no.lag <- cbind(NM.placebos.diff.vars.no.lag, nm.gaps.diff.vars.no.lag)
years <- seq(from=1995, to = 2018, by=1)


#### Illinois Placebo Prep
Illinois.placebos.diff.vars.no.lag <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Illinois <- dataprep(foo = death.set, time.predictors.prior = c(1995:2011), predictors = c("prison.rate.n", "Unemployment.Rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "officer_rate_per_1000"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 
  synth.out.11 <- synth(data.prep.obj = death.set.effect.Illinois, method = "All")
  death.set.effect.Illinois.gaps <- death.set.effect.Illinois$Y1plot - (death.set.effect.Illinois$Y0plot %*% synth.out.11$solution.w);
  Illinois.placebos.diff.vars.no.lag[,i] <- death.set.effect.Illinois.gaps
  i <- i + 1
}

final.Illinois.diff.vars.no.lag <- cbind(Illinois.placebos.diff.vars.no.lag, Illinois.gaps.diff.vars.no.lag)
years <- seq(from=1995, to = 2018, by=1)


#### Conn Placebo Prep
Conn.placebos.diff.vars.no.lag <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Conn <- dataprep(foo = death.set, time.predictors.prior = c(1995:2012), predictors = c("prison.rate.n", "Unemployment.Rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "officer_rate_per_1000"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 
  synth.out.12 <- synth(data.prep.obj = death.set.effect.Conn, method = "All")
  death.set.effect.Conn.gaps <- death.set.effect.Conn$Y1plot - (death.set.effect.Conn$Y0plot %*% synth.out.12$solution.w);
  Conn.placebos.diff.vars.no.lag[,i] <- death.set.effect.Conn.gaps
  i <- i + 1
}

final.Conn.diff.vars.no.lag <- cbind(Conn.placebos.diff.vars.no.lag, Conn.gaps.diff.vars.no.lag)
years <- seq(from=1995, to = 2018, by=1)


#### NJ Placebo Prep
NJ.placebos.diff.vars.no.lag <- matrix(nrow = 21, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NJ <- dataprep(foo = death.set, time.predictors.prior = c(1995:2007), predictors = c("prison.rate.n", "Unemployment.Rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "officer_rate_per_1000"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 
  synth.out.13 <- synth(data.prep.obj = death.set.effect.NJ, method = "All")
  death.set.effect.NJ.gaps <- death.set.effect.NJ$Y1plot - (death.set.effect.NJ$Y0plot %*% synth.out.13$solution.w);
  NJ.placebos.diff.vars.no.lag[,i] <- death.set.effect.NJ.gaps
  i <- i + 1
}

final.NJ.diff.vars.no.lag <- cbind(NJ.placebos.diff.vars.no.lag, NJ.gaps.diff.vars.no.lag)
years <- seq(from=1995, to = 2018, by=1)


#### Delaware Placebo Prep
Delaware.placebos.diff.vars.no.lag <- matrix(nrow = 24, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Delaware <- dataprep(foo = death.set, time.predictors.prior = c(1995:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "officer_rate_per_1000"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2016), time.plot = c(1995:2018)) 
  synth.out.14 <- synth(data.prep.obj = death.set.effect.Delaware, method = "All")
  death.set.effect.Delaware.gaps <- death.set.effect.Delaware$Y1plot - (death.set.effect.Delaware$Y0plot %*% synth.out.14$solution.w);
  Delaware.placebos.diff.vars.no.lag[,i] <- death.set.effect.Delaware.gaps
  i <- i + 1
}

final.Delaware.diff.vars.no.lag <- cbind(Delaware.placebos.diff.vars.no.lag, Delaware.gaps.diff.vars.no.lag)
years <- seq(from=1995, to = 2018, by=1)

#### Maryland Placebo Prep


maryland.placebos.diff.vars.no.lag <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.maryland <- dataprep(foo = death.set, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "officer_rate_per_1000"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 
  synth.out.8 <- synth(data.prep.obj = death.set.effect.maryland, method = "All")
  death.set.maryland.gaps <- death.set.effect.maryland$Y1plot - (death.set.effect.maryland$Y0plot %*% synth.out.8$solution.w);
  maryland.placebos.diff.vars.no.lag[,i] <- death.set.maryland.gaps
  i <- i + 1
}


final.maryland.diff.vars.no.lag <- cbind(maryland.placebos.diff.vars.no.lag, Maryland.gaps.diff.vars.no.lag)
years <- seq(from=1995, to = 2018, by=1)

########################################
########## Permutation Calculations ##########
########################################

ny.pre.gaps.diff.vars.no.lag <- final.ny.diff.vars.no.lag[1:10,]
ny.post.gaps.diff.vars.no.lag <- final.ny.diff.vars.no.lag[11:nrow(final.ny.diff.vars.no.lag),]

nm.pre.gaps.diff.vars.no.lag <- final.NM.diff.vars.no.lag[1:15,]
nm.post.gaps.diff.vars.no.lag <- final.NM.diff.vars.no.lag[16:nrow(final.NM.diff.vars.no.lag),]

Illinois.pre.gaps.diff.vars.no.lag <- final.Illinois.diff.vars.no.lag[1:17,]
Illinois.post.gaps.diff.vars.no.lag <- final.Illinois.diff.vars.no.lag[18:nrow(final.Illinois.diff.vars.no.lag),]

Conn.pre.gaps.diff.vars.no.lag <- final.Conn.diff.vars.no.lag[1:18,]
Conn.post.gaps.diff.vars.no.lag <- final.Conn.diff.vars.no.lag[19:nrow(final.Conn.diff.vars.no.lag),]

NJ.pre.gaps.diff.vars.no.lag <- final.NJ.diff.vars.no.lag[1:13,]
NJ.post.gaps.diff.vars.no.lag <- final.NJ.diff.vars.no.lag[14:nrow(final.NJ.diff.vars.no.lag),]

Delaware.pre.gaps.diff.vars.no.lag <- final.Delaware.diff.vars.no.lag[1:22,]
Delaware.post.gaps.diff.vars.no.lag <- final.Delaware.diff.vars.no.lag[23:nrow(final.Delaware.diff.vars.no.lag),]

Maryland.pre.gaps.diff.vars.no.lag <- final.maryland.diff.vars.no.lag[1:19,]
Maryland.post.gaps.diff.vars.no.lag <- final.maryland.diff.vars.no.lag[20:nrow(final.maryland.diff.vars.no.lag),]

diff.in.diff.ny.diff.vars.no.lag <- colMeans(ny.post.gaps.diff.vars.no.lag) - colMeans(ny.pre.gaps.diff.vars.no.lag)
diff.in.diff.ny.placebo.diff.vars.no.lag <- diff.in.diff.ny.diff.vars.no.lag[1:(length(diff.in.diff.ny.diff.vars.no.lag)-1)]
diff.in.diff.ny.actual.diff.vars.no.lag <- diff.in.diff.ny.diff.vars.no.lag[length(diff.in.diff.ny.diff.vars.no.lag)]

diff.in.diff.nm.diff.vars.no.lag <- colMeans(nm.post.gaps.diff.vars.no.lag) - colMeans(nm.pre.gaps.diff.vars.no.lag)
diff.in.diff.nm.placebo.diff.vars.no.lag <- diff.in.diff.nm.diff.vars.no.lag[1:(length(diff.in.diff.nm.diff.vars.no.lag)-1)]
diff.in.diff.nm.actual.diff.vars.no.lag <- diff.in.diff.nm.diff.vars.no.lag[length(diff.in.diff.nm.diff.vars.no.lag)]

diff.in.diff.Illinois.diff.vars.no.lag <- colMeans(Illinois.post.gaps.diff.vars.no.lag) - colMeans(Illinois.pre.gaps.diff.vars.no.lag)
diff.in.diff.Illinois.placebo.diff.vars.no.lag <- diff.in.diff.Illinois.diff.vars.no.lag[1:(length(diff.in.diff.Illinois.diff.vars.no.lag)-1)]
diff.in.diff.Illinois.actual.diff.vars.no.lag <- diff.in.diff.Illinois.diff.vars.no.lag[length(diff.in.diff.Illinois.diff.vars.no.lag)]

diff.in.diff.Conn.diff.vars.no.lag <- colMeans(Conn.post.gaps.diff.vars.no.lag) - colMeans(Conn.pre.gaps.diff.vars.no.lag)
diff.in.diff.Conn.placebo.diff.vars.no.lag <- diff.in.diff.Conn.diff.vars.no.lag[1:(length(diff.in.diff.Conn.diff.vars.no.lag)-1)]
diff.in.diff.Conn.actual.diff.vars.no.lag <- diff.in.diff.Conn.diff.vars.no.lag[length(diff.in.diff.Conn.diff.vars.no.lag)]

diff.in.diff.NJ.diff.vars.no.lag <- colMeans(NJ.post.gaps.diff.vars.no.lag) - colMeans(NJ.pre.gaps.diff.vars.no.lag)
diff.in.diff.NJ.placebo.diff.vars.no.lag <- diff.in.diff.NJ.diff.vars.no.lag[1:(length(diff.in.diff.NJ.diff.vars.no.lag)-1)]
diff.in.diff.NJ.actual.diff.vars.no.lag <- diff.in.diff.NJ.diff.vars.no.lag[length(diff.in.diff.NJ.diff.vars.no.lag)]

diff.in.diff.Delaware.diff.vars.no.lag <- colMeans(Delaware.post.gaps.diff.vars.no.lag) - colMeans(Delaware.pre.gaps.diff.vars.no.lag)
diff.in.diff.Delaware.placebo.diff.vars.no.lag <- diff.in.diff.Delaware.diff.vars.no.lag[1:(length(diff.in.diff.Delaware.diff.vars.no.lag)-1)]
diff.in.diff.Delaware.actual.diff.vars.no.lag <- diff.in.diff.Delaware.diff.vars.no.lag[length(diff.in.diff.Delaware.diff.vars.no.lag)]

diff.in.diff.Maryland.diff.vars.no.lag <- colMeans(Maryland.post.gaps.diff.vars.no.lag) - colMeans(Maryland.pre.gaps.diff.vars.no.lag)
diff.in.diff.Maryland.placebo.diff.vars.no.lag <- diff.in.diff.Maryland.diff.vars.no.lag[1:(length(diff.in.diff.Maryland.diff.vars.no.lag)-1)]
diff.in.diff.Maryland.actual.diff.vars.no.lag <- diff.in.diff.Maryland.diff.vars.no.lag[length(diff.in.diff.Maryland.diff.vars.no.lag)]

exceeds.ny.diff.vars.no.lag <- length(diff.in.diff.ny.placebo.diff.vars.no.lag[diff.in.diff.ny.placebo.diff.vars.no.lag>diff.in.diff.ny.actual.diff.vars.no.lag])  
less.than.ny.diff.vars.no.lag <- length(diff.in.diff.ny.placebo.diff.vars.no.lag)-exceeds.ny.diff.vars.no.lag

exceeds.nm.diff.vars.no.lag <- length(diff.in.diff.nm.placebo.diff.vars.no.lag[diff.in.diff.nm.placebo.diff.vars.no.lag>diff.in.diff.nm.actual.diff.vars.no.lag])  
less.than.nm.diff.vars.no.lag <- length(diff.in.diff.nm.placebo.diff.vars.no.lag)-exceeds.nm.diff.vars.no.lag

exceeds.Illinois.diff.vars.no.lag <- length(diff.in.diff.Illinois.placebo.diff.vars.no.lag[diff.in.diff.Illinois.placebo.diff.vars.no.lag>diff.in.diff.Illinois.actual.diff.vars.no.lag])  
less.than.Illinois.diff.vars.no.lag <- length(diff.in.diff.Illinois.placebo.diff.vars.no.lag)-exceeds.Illinois.diff.vars.no.lag

exceeds.Conn.diff.vars.no.lag <- length(diff.in.diff.Conn.placebo.diff.vars.no.lag[diff.in.diff.Conn.placebo.diff.vars.no.lag>diff.in.diff.Conn.actual.diff.vars.no.lag])  
less.than.Conn.diff.vars.no.lag <- length(diff.in.diff.Conn.placebo.diff.vars.no.lag)-exceeds.Conn.diff.vars.no.lag

exceeds.NJ.diff.vars.no.lag <- length(diff.in.diff.NJ.placebo.diff.vars.no.lag[diff.in.diff.NJ.placebo.diff.vars.no.lag>diff.in.diff.NJ.actual.diff.vars.no.lag])  
less.than.NJ.diff.vars.no.lag <- length(diff.in.diff.NJ.placebo.diff.vars.no.lag)-exceeds.NJ.diff.vars.no.lag

exceeds.Delaware.diff.vars.no.lag <- length(diff.in.diff.Delaware.placebo.diff.vars.no.lag[diff.in.diff.Delaware.placebo.diff.vars.no.lag>diff.in.diff.Delaware.actual.diff.vars.no.lag])  
less.than.Delaware.diff.vars.no.lag <- length(diff.in.diff.Delaware.placebo.diff.vars.no.lag)-exceeds.Delaware.diff.vars.no.lag

exceeds.Maryland.diff.vars.no.lag <- length(diff.in.diff.Maryland.placebo.diff.vars.no.lag[diff.in.diff.Maryland.placebo.diff.vars.no.lag>diff.in.diff.Maryland.actual.diff.vars.no.lag])  
less.than.Maryland.diff.vars.no.lag <- length(diff.in.diff.Maryland.placebo.diff.vars.no.lag)-exceeds.Maryland.diff.vars.no.lag

container.matrix.diff.vars.no.lag <- matrix(nrow = 7, ncol = 5)
container.matrix.diff.vars.no.lag[1,] <- c("New York", round(diff.in.diff.ny.actual.diff.vars.no.lag, 2), exceeds.ny.diff.vars.no.lag, less.than.ny.diff.vars.no.lag, round((exceeds.ny.diff.vars.no.lag/29), 2))
container.matrix.diff.vars.no.lag[2,] <- c("New Mexico", round(diff.in.diff.nm.actual.diff.vars.no.lag, 2), exceeds.nm.diff.vars.no.lag, less.than.nm.diff.vars.no.lag, round((exceeds.nm.diff.vars.no.lag/29), 2))
container.matrix.diff.vars.no.lag[3,] <- c("Illinois", round(diff.in.diff.Illinois.actual.diff.vars.no.lag, 2), exceeds.Illinois.diff.vars.no.lag, less.than.Illinois.diff.vars.no.lag, round((exceeds.Illinois.diff.vars.no.lag/29), 2))
container.matrix.diff.vars.no.lag[4,] <- c("Connecticut", round(diff.in.diff.Conn.actual.diff.vars.no.lag, 2), exceeds.Conn.diff.vars.no.lag, less.than.Conn.diff.vars.no.lag, round((exceeds.Conn.diff.vars.no.lag/29), 2))
container.matrix.diff.vars.no.lag[5,] <- c("New Jersey", round(diff.in.diff.NJ.actual.diff.vars.no.lag, 2), exceeds.NJ.diff.vars.no.lag, less.than.NJ.diff.vars.no.lag, round((exceeds.NJ.diff.vars.no.lag/29), 2))
container.matrix.diff.vars.no.lag[6,] <- c("Delaware", round(diff.in.diff.Delaware.actual.diff.vars.no.lag, 2), exceeds.Delaware.diff.vars.no.lag, less.than.Delaware.diff.vars.no.lag, round((exceeds.Delaware.diff.vars.no.lag/29), 2))
container.matrix.diff.vars.no.lag[7,] <- c("Maryland", round(diff.in.diff.Maryland.actual.diff.vars.no.lag, 2), exceeds.Maryland.diff.vars.no.lag, less.than.Maryland.diff.vars.no.lag, round((exceeds.Maryland.diff.vars.no.lag/29), 2))

sum.stats.diff.vars.no.lag <- as.data.frame(container.matrix.diff.vars.no.lag)

rmpse.ratios.ny.diff.vars.no.lag <- sqrt(colMeans(ny.post.gaps.diff.vars.no.lag^2))/sqrt(colMeans(ny.pre.gaps.diff.vars.no.lag^2))

names(rmpse.ratios.ny.diff.vars.no.lag) <- c(unique(death.set$State), "New York")
  
dotchart(sort(rmpse.ratios.ny.diff.vars.no.lag),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 22), "red", rep("black", 11)))

rmpse.ratios.nm.diff.vars.no.lag <- sqrt(colMeans(nm.post.gaps.diff.vars.no.lag^2))/sqrt(colMeans(nm.pre.gaps.diff.vars.no.lag^2))

names(rmpse.ratios.nm.diff.vars.no.lag) <- c(unique(death.set$State), "New Mexico")
  
dotchart(sort(rmpse.ratios.nm.diff.vars.no.lag),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 6), "red", rep("black", 23)))

rmpse.ratios.Illinois.diff.vars.no.lag <- sqrt(colMeans(Illinois.post.gaps.diff.vars.no.lag^2))/sqrt(colMeans(Illinois.pre.gaps.diff.vars.no.lag^2))

names(rmpse.ratios.Illinois.diff.vars.no.lag) <- c(unique(death.set$State), "Illinois")
  
dotchart(sort(rmpse.ratios.Illinois.diff.vars.no.lag),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 26), "red", rep("black", 7)))


rmpse.ratios.Conn.diff.vars.no.lag <- sqrt(colMeans(Conn.post.gaps.diff.vars.no.lag^2))/sqrt(colMeans(Conn.pre.gaps.diff.vars.no.lag^2))

names(rmpse.ratios.Conn.diff.vars.no.lag) <- c(unique(death.set$State), "Connecticut")
  
dotchart(sort(rmpse.ratios.Conn.diff.vars.no.lag),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 27), "red", rep("black", 5)))


rmpse.ratios.NJ.diff.vars.no.lag <- sqrt(colMeans(NJ.post.gaps.diff.vars.no.lag^2))/sqrt(colMeans(NJ.pre.gaps.diff.vars.no.lag^2))

names(rmpse.ratios.NJ.diff.vars.no.lag) <- c(unique(death.set$State), "New Jersey")
  
dotchart(sort(rmpse.ratios.NJ.diff.vars.no.lag),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 11), "red", rep("black", 19)))


rmpse.ratios.Delaware.diff.vars.no.lag <- sqrt(colMeans(Delaware.post.gaps.diff.vars.no.lag^2))/sqrt(colMeans(Delaware.pre.gaps.diff.vars.no.lag^2))

names(rmpse.ratios.Delaware.diff.vars.no.lag) <- c(unique(death.set$State), "Delaware")
  
dotchart(sort(rmpse.ratios.Delaware.diff.vars.no.lag),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 6), "red", rep("black", 26)))


rmpse.ratios.Maryland.diff.vars.no.lag <- sqrt(colMeans(Maryland.post.gaps.diff.vars.no.lag^2))/sqrt(colMeans(Maryland.pre.gaps.diff.vars.no.lag^2))

names(rmpse.ratios.Maryland.diff.vars.no.lag) <- c(unique(death.set$State), "Maryland")
  
dotchart(sort(rmpse.ratios.Maryland.diff.vars.no.lag),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 14), "red", rep("black", 7)))


par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))

dotchart(sort(rmpse.ratios.ny.diff.vars.no.lag),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 22), "red", rep("black", 11)))

dotchart(sort(rmpse.ratios.nm.diff.vars.no.lag),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 6), "red", rep("black", 23)))

mtext("Figure X: Ratios of Post-Treatment RMSPE to Pre-Treatment RMSPE", side = 3, line = 4, font = 2)

dotchart(sort(rmpse.ratios.Illinois.diff.vars.no.lag),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 26), "red", rep("black", 7)))

dotchart(sort(rmpse.ratios.Conn.diff.vars.no.lag),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 27), "red", rep("black", 5)))

dotchart(sort(rmpse.ratios.NJ.diff.vars.no.lag),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 11), "red", rep("black", 19)))

dotchart(sort(rmpse.ratios.Delaware.diff.vars.no.lag),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 6), "red", rep("black", 26)))

dotchart(sort(rmpse.ratios.Maryland.diff.vars.no.lag),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 14), "red", rep("black", 7)))



###########################################################################################################################


new.york.effect.nb.nl <- dataprep(foo = NY.Set.nb, time.predictors.prior = c(1995:2004), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 36, controls.identifier = c(1:21, 23:29), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 

synth.out.nb.nl <- synth(data.prep.obj = new.york.effect.nb.nl, method = "All")

ny.tables.nb.nl <- synth.tab(dataprep.res = new.york.effect.nb.nl, synth.res = synth.out.nb.nl)

path.plot(synth.res = synth.out.nb.nl, dataprep.res = new.york.effect.nb.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004)

ny.gaps.nb.nl <- new.york.effect.nb.nl$Y1plot - (new.york.effect.nb.nl$Y0plot %*% synth.out.nb.nl$solution.w)


### New Mexico

nm.effect.nb.nl <- dataprep(foo = NM.Set.nb, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 40, controls.identifier = c(1,3,4,6:19,21:25, 28, 29), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 

synth.out.2.nb.nl <- synth(data.prep.obj = nm.effect.nb.nl, method = "All")

nm.tables.nb.nl <- synth.tab(dataprep.res = nm.effect.nb.nl, synth.res = synth.out.2.nb.nl)


path.plot(synth.res = synth.out.2.nb.nl, dataprep.res = nm.effect.nb.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009)

nm.gaps.nb.nl <- nm.effect.nb.nl$Y1plot - (nm.effect.nb.nl$Y0plot %*% synth.out.2.nb.nl$solution.w)


### Illinois 


Illinois.effect.nb.nl <- dataprep(foo = Illinois.Set.nb, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 39, controls.identifier = c(1:8,10,12,13,15:29), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 

synth.out.3.nb.nl <- synth(data.prep.obj = Illinois.effect.nb.nl, method = "All")

Illinois.tables.nb.nl <- synth.tab(dataprep.res = Illinois.effect.nb.nl, synth.res = synth.out.3.nb.nl)

path.plot(synth.res = synth.out.3.nb.nl, dataprep.res = Illinois.effect.nb.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011)

Illinois.gaps.nb.nl <- Illinois.effect.nb.nl$Y1plot - (Illinois.effect.nb.nl$Y0plot %*% synth.out.3.nb.nl$solution.w)


### Connecticut

Conn.effect.nb.nl <- dataprep(foo = Conn.Set, time.predictors.prior = c(1995:2012), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 41, controls.identifier = c(1:29), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 

synth.out.4.nb.nl <- synth(data.prep.obj = Conn.effect.nb.nl, method = "All")

Conn.tables.nb.nl <- synth.tab(dataprep.res = Conn.effect.nb.nl, synth.res = synth.out.4.nb.nl)

path.plot(synth.res = synth.out.4.nb.nl, dataprep.res = Conn.effect.nb.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012)

Conn.gaps.nb.nl <- Conn.effect.nb.nl$Y1plot - (Conn.effect.nb.nl$Y0plot %*% synth.out.4.nb.nl$solution.w)


### New Jersey


NJ.effect.nb.nl <- dataprep(foo = NJ.Set.nb, time.predictors.prior = c(1995:2007), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 42, controls.identifier = c(1:21, 23:29), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 

synth.out.5.nb.nl <- synth(data.prep.obj = NJ.effect.nb.nl, method = "All")

NJ.tables.nb.nl <- synth.tab(dataprep.res = NJ.effect.nb.nl, synth.res = synth.out.5.nb.nl)

path.plot(synth.res = synth.out.5.nb.nl, dataprep.res = NJ.effect.nb.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007)

NJ.gaps.nb.nl <- NJ.effect.nb.nl$Y1plot - (NJ.effect.nb.nl$Y0plot %*% synth.out.5.nb.nl$solution.w)

### Delaware

Delaware.effect.nb.nl <- dataprep(foo = Delaware.Set.nb, time.predictors.prior = c(1995:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 38, controls.identifier = c(1:21, 23:29), time.optimize.ssr = c(1995:2016), time.plot = c(1995:2018)) 

synth.out.6.nb.nl <- synth(data.prep.obj = Delaware.effect.nb.nl, method = "All")

Delaware.tables.nb.nl <- synth.tab(dataprep.res = Delaware.effect.nb.nl, synth.res = synth.out.6.nb.nl)


path.plot(synth.res = synth.out.6.nb.nl, dataprep.res = Delaware.effect.nb.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016)

Delaware.gaps.nb.nl <- Delaware.effect.nb.nl$Y1plot - (Delaware.effect.nb.nl$Y0plot %*% synth.out.6.nb.nl$solution.w)

### Maryland


Maryland.effect.nb.nl <- dataprep(foo = Maryland.Set.nb, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = 37, controls.identifier = c(1:21,23:27, 29), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 

synth.out.7.nb.nl <- synth(data.prep.obj = Maryland.effect.nb.nl, method = "All")

path.plot(synth.res = synth.out.7.nb.nl, dataprep.res = Maryland.effect.nb.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013)

Maryland.tables.nb.nl <- synth.tab(dataprep.res = Maryland.effect.nb.nl, synth.res = synth.out.7.nb.nl)

Maryland.gaps.nb.nl <- Maryland.effect.nb.nl$Y1plot - (Maryland.effect.nb.nl$Y0plot %*% synth.out.7.nb.nl$solution.w)



############### ############### ############### 
############### Single Plot ###############
############### ############### ############### 



### New York 

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))
path.plot(synth.res = synth.out.nb.nl, dataprep.res = new.york.effect.nb.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004, col = "red")

### New Mexico


path.plot(synth.res = synth.out.2.nb.nl, dataprep.res = nm.effect.nb.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009, col = "red")
mtext("Figure X: Strengthening No Spillover Assumption By Removing Bordering States (y = Log Murders Per 100,000 Residents)", side = 3, line = 4, font = 2)

### Illinois 


path.plot(synth.res = synth.out.3.nb.nl, dataprep.res = Illinois.effect.nb.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011, col = "red")



### Connecticut


path.plot(synth.res = synth.out.4.nb.nl, dataprep.res = Conn.effect.nb.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012, col = "red")


### New Jersey


path.plot(synth.res = synth.out.5.nb.nl, dataprep.res = NJ.effect.nb.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007, col = "red")


### Delaware


path.plot(synth.res = synth.out.6.nb.nl, dataprep.res = Delaware.effect.nb.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016, col = "red")


### Maryland

path.plot(synth.res = synth.out.7.nb.nl, dataprep.res = Maryland.effect.nb.nl, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013, col = "red")

legend.cols <- c("black", "black", "red")
names(legend.cols) <- c("Treated", "Synthetic Control", "Year Eliminated DP")
par(fig= c(0, 1, 0, 1), oma = c(0,0,0,0), mar = c(.5, .5, .5, .5), new=TRUE)
plot(0,0, type = "n", bty="n", xaxt ="n", yaxt="n")
legend("bottom", text.width=c(0.3,0.3,0.3), legend=names(legend.cols), col = legend.cols, lty = c(1,2,1), lwd = c(2.5, 2.5, 2.5), cex = .75, xpd = TRUE, horiz = F, inset = c(0,0,0), bty = "y", text.font = 2)



ny.placebos.nb.nl <- matrix(nrow = 21, ncol = 28)
i <- 1
for (s in c(1:21, 23:29)) {
  controls <- c(1:21, 23:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.ny <- dataprep(foo = death.set.nb.1, time.predictors.prior = c(1995:2004), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2004), time.plot = c(1995:2015)) 
  synth.out.9 <- synth(data.prep.obj = death.set.effect.ny, method = "All")
  death.set.effect.ny.gaps <- death.set.effect.ny$Y1plot - (death.set.effect.ny$Y0plot %*% synth.out.9$solution.w);
  ny.placebos.nb.nl[,i] <- death.set.effect.ny.gaps
  i <- i + 1
}

final.ny.nb.nl <- cbind(ny.placebos.nb.nl, ny.gaps.nb.nl)
years <- seq(from=1995, to = 2018, by=1)

#### NM Placebo Prep

NM.placebos.nb.nl <- matrix(nrow = 21, ncol = 24)
i <- 1
for (s in c(1,3,4,6:19,21:25, 28, 29)) {
  controls <- c(1,3,4,6:19,21:25, 28, 29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NM <- dataprep(foo = death.set.nb.2, time.predictors.prior = c(1995:2009), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2009), time.plot = c(1995:2015)) 
  synth.out.10 <- synth(data.prep.obj = death.set.effect.NM, method = "All")
  death.set.effect.nm.gaps <- death.set.effect.NM$Y1plot - (death.set.effect.NM$Y0plot %*% synth.out.10$solution.w);
  NM.placebos.nb.nl[,i] <- death.set.effect.nm.gaps
  i <- i + 1
}

final.NM.nb.nl <- cbind(NM.placebos.nb.nl, nm.gaps.nb.nl)
years <- seq(from=1995, to = 2018, by=1)


#### Illinois Placebo Prep


Illinois.placebos.nb.nl <- matrix(nrow = 23, ncol = 26)
i <- 1
for (s in c(1:8,10,12,13,15:29)) {
  controls <- c(1:8,10,12,13,15:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Illinois <- dataprep(foo = death.set.nb.3, time.predictors.prior = c(1995:2011), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2011), time.plot = c(1995:2017)) 
  synth.out.11 <- synth(data.prep.obj = death.set.effect.Illinois, method = "All")
  death.set.effect.Illinois.gaps <- death.set.effect.Illinois$Y1plot - (death.set.effect.Illinois$Y0plot %*% synth.out.11$solution.w);
  Illinois.placebos.nb.nl[,i] <- death.set.effect.Illinois.gaps
  i <- i + 1
}

final.Illinois.nb.nl <- cbind(Illinois.placebos.nb.nl, Illinois.gaps.nb.nl)
years <- seq(from=1995, to = 2018, by=1)


#### Conn Placebo Prep
Conn.placebos.nb.nl <- matrix(nrow = 23, ncol = 29)
i <- 1
for (s in 1:29) {
  controls <- c(1:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Conn <- dataprep(foo = death.set, time.predictors.prior = c(1995:2012), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2012), time.plot = c(1995:2017)) 
  synth.out.12 <- synth(data.prep.obj = death.set.effect.Conn, method = "All")
  death.set.effect.Conn.gaps <- death.set.effect.Conn$Y1plot - (death.set.effect.Conn$Y0plot %*% synth.out.12$solution.w);
  Conn.placebos.nb.nl[,i] <- death.set.effect.Conn.gaps
  i <- i + 1
}

final.Conn.nb.nl <- cbind(Conn.placebos.nb.nl, Conn.gaps.nb.nl)
years <- seq(from=1995, to = 2018, by=1)


#### NJ Placebo Prep


NJ.placebos.nb.nl <- matrix(nrow = 21, ncol = 28)
i <- 1
for (s in c(1:21, 23:29)) {
  controls <- c(1:21, 23:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.NJ <- dataprep(foo = death.set.nb.5, time.predictors.prior = c(1995:2007), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "inequality", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2007), time.plot = c(1995:2015)) 
  synth.out.13 <- synth(data.prep.obj = death.set.effect.NJ, method = "All")
  death.set.effect.NJ.gaps <- death.set.effect.NJ$Y1plot - (death.set.effect.NJ$Y0plot %*% synth.out.13$solution.w);
  NJ.placebos.nb.nl[,i] <- death.set.effect.NJ.gaps
  i <- i + 1
}

final.NJ.nb.nl <- cbind(NJ.placebos.nb.nl, NJ.gaps.nb.nl)
years <- seq(from=1995, to = 2018, by=1)


#### Delaware Placebo Prep


Delaware.placebos.nb.nl <- matrix(nrow = 24, ncol = 28)
i <- 1
for (s in c(1:21, 23:29)) {
  controls <- c(1:21, 23:29)
  controls.complete <- controls[controls!=s]
  death.set.effect.Delaware <- dataprep(foo = death.set.nb.6, time.predictors.prior = c(1995:2016), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2016), time.plot = c(1995:2018)) 
  synth.out.14 <- synth(data.prep.obj = death.set.effect.Delaware, method = "All")
  death.set.effect.Delaware.gaps <- death.set.effect.Delaware$Y1plot - (death.set.effect.Delaware$Y0plot %*% synth.out.14$solution.w);
  Delaware.placebos.nb.nl[,i] <- death.set.effect.Delaware.gaps
  i <- i + 1
}

final.Delaware.nb.nl <- cbind(Delaware.placebos.nb.nl, Delaware.gaps.nb.nl)
years <- seq(from=1995, to = 2018, by=1)

#### Maryland Placebo Prep


maryland.placebos.nb.nl <- matrix(nrow = 23, ncol = 27)
i <- 1
for (s in c(1:21,23:27, 29)) {
  controls <- c(1:21,23:27, 29)
  controls.complete <- controls[controls!=s]
  death.set.effect.maryland <- dataprep(foo = death.set.nb.7, time.predictors.prior = c(1995:2013), predictors = c("crime.rate", "Unemployment.Rate", "robbery.rate", "pop.den.n", "proportion.15.29", "gdp.per.n", "poverty", "police.direct.expen.pc"), dependent = "log.murder.rate", unit.variable = "number", unit.names.variable = "State", time.variable = "Year", treatment.identifier = s, controls.identifier = c(controls.complete), time.optimize.ssr = c(1995:2013), time.plot = c(1995:2017)) 
  synth.out.8 <- synth(data.prep.obj = death.set.effect.maryland, method = "All")
  death.set.maryland.gaps <- death.set.effect.maryland$Y1plot - (death.set.effect.maryland$Y0plot %*% synth.out.8$solution.w);
  maryland.placebos.nb.nl[,i] <- death.set.maryland.gaps
  i <- i + 1
}


final.maryland.nb.nl <- cbind(maryland.placebos.nb.nl, Maryland.gaps.nb.nl)
years <- seq(from=1995, to = 2018, by=1)



########################################
########## Permutation Calculations ##########
########################################

ny.pre.gaps.nb.nl <- final.ny.nb.nl[1:10,]
ny.post.gaps.nb.nl <- final.ny.nb.nl[11:nrow(final.ny.nb.nl),]

nm.pre.gaps.nb.nl <- final.NM.nb.nl[1:15,]
nm.post.gaps.nb.nl <- final.NM.nb.nl[16:nrow(final.NM.nb.nl),]

Illinois.pre.gaps.nb.nl <- final.Illinois.nb.nl[1:17,]
Illinois.post.gaps.nb.nl <- final.Illinois.nb.nl[18:nrow(final.Illinois.nb.nl),]

Conn.pre.gaps.nb.nl <- final.Conn.nb.nl[1:18,]
Conn.post.gaps.nb.nl <- final.Conn.nb.nl[19:nrow(final.Conn.nb.nl),]

NJ.pre.gaps.nb.nl <- final.NJ.nb.nl[1:13,]
NJ.post.gaps.nb.nl <- final.NJ.nb.nl[14:nrow(final.NJ.nb.nl),]

Delaware.pre.gaps.nb.nl <- final.Delaware.nb.nl[1:22,]
Delaware.post.gaps.nb.nl <- final.Delaware.nb.nl[23:nrow(final.Delaware.nb.nl),]

Maryland.pre.gaps.nb.nl <- final.maryland.nb.nl[1:19,]
Maryland.post.gaps.nb.nl <- final.maryland.nb.nl[20:nrow(final.maryland.nb.nl),]

diff.in.diff.ny.nb.nl <- colMeans(ny.post.gaps.nb.nl) - colMeans(ny.pre.gaps.nb.nl)
diff.in.diff.ny.placebo.nb.nl <- diff.in.diff.ny.nb.nl[1:(length(diff.in.diff.ny.nb.nl)-1)]
diff.in.diff.ny.actual.nb.nl <- diff.in.diff.ny.nb.nl[length(diff.in.diff.ny.nb.nl)]

diff.in.diff.nm.nb.nl <- colMeans(nm.post.gaps.nb.nl) - colMeans(nm.pre.gaps.nb.nl)
diff.in.diff.nm.placebo.nb.nl <- diff.in.diff.nm.nb.nl[1:(length(diff.in.diff.nm.nb.nl)-1)]
diff.in.diff.nm.actual.nb.nl <- diff.in.diff.nm.nb.nl[length(diff.in.diff.nm.nb.nl)]

diff.in.diff.Illinois.nb.nl <- colMeans(Illinois.post.gaps.nb.nl) - colMeans(Illinois.pre.gaps.nb.nl)
diff.in.diff.Illinois.placebo.nb.nl <- diff.in.diff.Illinois.nb.nl[1:(length(diff.in.diff.Illinois.nb.nl)-1)]
diff.in.diff.Illinois.actual.nb.nl <- diff.in.diff.Illinois.nb.nl[length(diff.in.diff.Illinois.nb.nl)]

diff.in.diff.Conn.nb.nl <- colMeans(Conn.post.gaps.nb.nl) - colMeans(Conn.pre.gaps.nb.nl)
diff.in.diff.Conn.placebo.nb.nl <- diff.in.diff.Conn.nb.nl[1:(length(diff.in.diff.Conn.nb.nl)-1)]
diff.in.diff.Conn.actual.nb.nl <- diff.in.diff.Conn.nb.nl[length(diff.in.diff.Conn.nb.nl)]

diff.in.diff.NJ.nb.nl <- colMeans(NJ.post.gaps.nb.nl) - colMeans(NJ.pre.gaps.nb.nl)
diff.in.diff.NJ.placebo.nb.nl <- diff.in.diff.NJ.nb.nl[1:(length(diff.in.diff.NJ.nb.nl)-1)]
diff.in.diff.NJ.actual.nb.nl <- diff.in.diff.NJ.nb.nl[length(diff.in.diff.NJ.nb.nl)]

diff.in.diff.Delaware.nb.nl <- colMeans(Delaware.post.gaps.nb.nl) - colMeans(Delaware.pre.gaps.nb.nl)
diff.in.diff.Delaware.placebo.nb.nl <- diff.in.diff.Delaware.nb.nl[1:(length(diff.in.diff.Delaware.nb.nl)-1)]
diff.in.diff.Delaware.actual.nb.nl <- diff.in.diff.Delaware.nb.nl[length(diff.in.diff.Delaware.nb.nl)]

diff.in.diff.Maryland.nb.nl <- colMeans(Maryland.post.gaps.nb.nl) - colMeans(Maryland.pre.gaps.nb.nl)
diff.in.diff.Maryland.placebo.nb.nl <- diff.in.diff.Maryland.nb.nl[1:(length(diff.in.diff.Maryland.nb.nl)-1)]
diff.in.diff.Maryland.actual.nb.nl <- diff.in.diff.Maryland.nb.nl[length(diff.in.diff.Maryland.nb.nl)]

exceeds.ny.nb.nl <- length(diff.in.diff.ny.placebo.nb.nl[diff.in.diff.ny.placebo.nb.nl>diff.in.diff.ny.actual.nb.nl])  
less.than.ny.nb.nl <- length(diff.in.diff.ny.placebo.nb.nl)-exceeds.ny.nb.nl

exceeds.nm.nb.nl <- length(diff.in.diff.nm.placebo.nb.nl[diff.in.diff.nm.placebo.nb.nl>diff.in.diff.nm.actual.nb.nl])  
less.than.nm.nb.nl <- length(diff.in.diff.nm.placebo.nb.nl)-exceeds.nm.nb.nl

exceeds.Illinois.nb.nl <- length(diff.in.diff.Illinois.placebo.nb.nl[diff.in.diff.Illinois.placebo.nb.nl>diff.in.diff.Illinois.actual.nb.nl])  
less.than.Illinois.nb.nl <- length(diff.in.diff.Illinois.placebo.nb.nl)-exceeds.Illinois.nb.nl

exceeds.Conn.nb.nl <- length(diff.in.diff.Conn.placebo.nb.nl[diff.in.diff.Conn.placebo.nb.nl>diff.in.diff.Conn.actual.nb.nl])  
less.than.Conn.nb.nl <- length(diff.in.diff.Conn.placebo.nb.nl)-exceeds.Conn.nb.nl

exceeds.NJ.nb.nl <- length(diff.in.diff.NJ.placebo.nb.nl[diff.in.diff.NJ.placebo.nb.nl>diff.in.diff.NJ.actual.nb.nl])  
less.than.NJ.nb.nl <- length(diff.in.diff.NJ.placebo.nb.nl)-exceeds.NJ.nb.nl

exceeds.Delaware.nb.nl <- length(diff.in.diff.Delaware.placebo.nb.nl[diff.in.diff.Delaware.placebo.nb.nl>diff.in.diff.Delaware.actual.nb.nl])  
less.than.Delaware.nb.nl <- length(diff.in.diff.Delaware.placebo.nb.nl)-exceeds.Delaware.nb.nl

exceeds.Maryland.nb.nl <- length(diff.in.diff.Maryland.placebo.nb.nl[diff.in.diff.Maryland.placebo.nb.nl>diff.in.diff.Maryland.actual.nb.nl])  
less.than.Maryland.nb.nl <- length(diff.in.diff.Maryland.placebo.nb.nl)-exceeds.Maryland.nb.nl

container.matrix.nb.nl <- matrix(nrow = 7, ncol = 5)
container.matrix.nb.nl[1,] <- c("New York", round(diff.in.diff.ny.actual.nb.nl, 2), exceeds.ny.nb.nl, less.than.ny.nb.nl, round((exceeds.ny.nb.nl/28), 2))
container.matrix.nb.nl[2,] <- c("New Mexico", round(diff.in.diff.nm.actual.nb.nl, 2), exceeds.nm.nb.nl, less.than.nm.nb.nl, round((exceeds.nm.nb.nl/24), 2))
container.matrix.nb.nl[3,] <- c("Illinois", round(diff.in.diff.Illinois.actual.nb.nl, 2), exceeds.Illinois.nb.nl, less.than.Illinois.nb.nl, round((exceeds.Illinois.nb.nl/26), 2))
container.matrix.nb.nl[4,] <- c("Connecticut", round(diff.in.diff.Conn.actual.nb.nl, 2), exceeds.Conn.nb.nl, less.than.Conn.nb.nl, round((exceeds.Conn.nb.nl/29), 2))
container.matrix.nb.nl[5,] <- c("New Jersey", round(diff.in.diff.NJ.actual.nb.nl, 2), exceeds.NJ.nb.nl, less.than.NJ.nb.nl, round((exceeds.NJ.nb.nl/28), 2))
container.matrix.nb.nl[6,] <- c("Delaware", round(diff.in.diff.Delaware.actual.nb.nl, 2), exceeds.Delaware.nb.nl, less.than.Delaware.nb.nl, round((exceeds.Delaware.nb.nl/28), 2))
container.matrix.nb.nl[7,] <- c("Maryland", round(diff.in.diff.Maryland.actual.nb.nl, 2), exceeds.Maryland.nb.nl, less.than.Maryland.nb.nl, round((exceeds.Maryland.nb.nl/27), 2))

rmpse.ratios.ny.nb.nl <- sqrt(colMeans(ny.post.gaps.nb.nl^2))/sqrt(colMeans(ny.pre.gaps.nb.nl^2))

names(rmpse.ratios.ny.nb.nl) <- c(unique(death.set.nb.1$State), "New York")
  
dotchart(sort(rmpse.ratios.ny.nb.nl),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 23), "red", rep("black", 11)))

rmpse.ratios.nm.nb.nl <- sqrt(colMeans(nm.post.gaps.nb.nl^2))/sqrt(colMeans(nm.pre.gaps.nb.nl^2))

state.names.death.set.nb.2 <- unique(death.set.nb.2$State)

names(rmpse.ratios.nm.nb.nl) <- c(state.names.death.set.nb.2, "New Mexico")
  
dotchart(sort(rmpse.ratios.nm.nb.nl),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 13), "red", rep("black", 11)))

rmpse.ratios.Illinois.nb.nl <- sqrt(colMeans(Illinois.post.gaps.nb.nl^2))/sqrt(colMeans(Illinois.pre.gaps.nb.nl^2))

names(rmpse.ratios.Illinois.nb.nl) <- c(unique(death.set.nb.3$State), "Illinois")
  
dotchart(sort(rmpse.ratios.Illinois.nb.nl),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 19), "red", rep("black", 7)))


rmpse.ratios.Conn.nb.nl <- sqrt(colMeans(Conn.post.gaps.nb.nl^2))/sqrt(colMeans(Conn.pre.gaps.nb.nl^2))

names(rmpse.ratios.Conn.nb.nl) <- c(state.names.death.set, "Connecticut")
  
dotchart(sort(rmpse.ratios.Conn.nb.nl),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 24), "red", rep("black", 5)))


rmpse.ratios.NJ.nb.nl <- sqrt(colMeans(NJ.post.gaps.nb.nl^2))/sqrt(colMeans(NJ.pre.gaps.nb.nl^2))

names(rmpse.ratios.NJ.nb.nl) <- c(unique(death.set.nb.5$State), "New Jersey")
  
dotchart(sort(rmpse.ratios.NJ.nb.nl),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 18), "red", rep("black", 10)))


rmpse.ratios.Delaware.nb.nl <- sqrt(colMeans(Delaware.post.gaps.nb.nl^2))/sqrt(colMeans(Delaware.pre.gaps.nb.nl^2))

names(rmpse.ratios.Delaware.nb.nl) <- c(unique(death.set.nb.6$State), "Delaware")
  
dotchart(sort(rmpse.ratios.Delaware.nb.nl),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 2), "red", rep("black", 26)))


rmpse.ratios.Maryland.nb.nl <- sqrt(colMeans(Maryland.post.gaps.nb.nl^2))/sqrt(colMeans(Maryland.pre.gaps.nb.nl^2))

names(rmpse.ratios.Maryland.nb.nl) <- c(unique(death.set.nb.7$State), "Maryland")
  
dotchart(sort(rmpse.ratios.Maryland.nb.nl),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 22), "red", rep("black", 7)))


par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))

dotchart(sort(rmpse.ratios.ny.nb.nl),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 23), "red", rep("black", 11)))

dotchart(sort(rmpse.ratios.nm.nb.nl),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 13), "red", rep("black", 11)))

mtext("Figure X: Ratios of Post-Treatment RMSPE to Pre-Treatment RMSPE", side = 3, line = 4, font = 2)

dotchart(sort(rmpse.ratios.Illinois.nb.nl),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 19), "red", rep("black", 7)))

dotchart(sort(rmpse.ratios.Conn.nb.nl),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 24), "red", rep("black", 5)))

dotchart(sort(rmpse.ratios.NJ.nb.nl),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 18), "red", rep("black", 10)))

dotchart(sort(rmpse.ratios.Delaware.nb.nl),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 2), "red", rep("black", 26)))

dotchart(sort(rmpse.ratios.Maryland.nb.nl),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 22), "red", rep("black", 7)))



huge.table.2 <- rbind(container.matrix.nb.nl, container.matrix.diff.vars.no.lag)

```

\singlespacing
\begin{longtable}{c>{\bfseries\centering\arraybackslash}p{2cm}>{\bfseries\centering\arraybackslash}p{2cm}>{\bfseries\centering\arraybackslash}p{2cm}>{\bfseries\centering\arraybackslash}p{2cm}}
\toprule
\multicolumn{5}{c}{\bgroup\fontsize{12}{14}\selectfont \textbf{Table A.5: Testing Alternative Specifications With No Lags}\egroup{}} \\
\cmidrule(l{3pt}r{3pt}){1-5}
\textbf{State} & \textbf{Estimated Deterrence Effect} & \textbf{Placebos With Larger Deterrence Effects} & \textbf{Placebos With Smaller Deterrence Effects} & \textbf{Proportion of Placebos With Larger Deterrence Effect}\\
\midrule
\endfirsthead
\multicolumn{5}{@{}l}{\textit{(continued)}}\\
\toprule
\textbf{State} & \textbf{Estimated Deterrence Effect} & \textbf{Placebos With Larger Deterrence Effects} & \textbf{Placebos With Smaller Deterrence Effects} & \textbf{Proportion of Placebos With Larger Deterrence Effect}\\
\midrule
\endhead
\
\endfoot
\bottomrule
\endlastfoot
\addlinespace[0.3em]
\multicolumn{5}{l}{\textbf{Bordering States Removed}}\\
\hspace{1em}New York & -0.26 & 26 & 2 & 0.93\\
\hspace{1em}New Mexico & -0.16 & 20 & 4 & 0.83\\
\hspace{1em}Illinois & 0.15 & 2 & 24 & 0.08\\
\hspace{1em}Connecticut & -0.17 & 27 & 2 & \vphantom{1} 0.93\\
\hspace{1em}New Jersey & 0.02 & 12 & 16 & 0.43\\
\hspace{1em}Delaware & -0.02 & 17 & 11 & 0.61\\
\hspace{1em}Maryland & 0.07 & 11 & 16 & 0.41\\
\addlinespace[0.3em]
\multicolumn{5}{l}{\textbf{Alternative Predictor Variables}}\\
\hspace{1em}New York & -0.17 & 26 & 3 & 0.9\\
\hspace{1em}New Mexico & -0.07 & 22 & 7 & 0.76\\
\hspace{1em}Illinois & 0.11 & 2 & 27 & 0.07\\
\hspace{1em}Connecticut & -0.17 & 27 & 2 & 0.93\\
\hspace{1em}New Jersey & 0.07 & 7 & 22 & 0.24\\
\hspace{1em}Delaware & 0.3 & 3 & 26 & 0.1\\
\hspace{1em}Maryland & 0.01 & 13 & 16 & 0.45\\*
\end{longtable}
\doublespacing

```{r, echo=FALSE, warning=FALSE, fig.width=14, fig.align="center", fig.height=8, out.width="7in"}

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))

dotchart(sort(rmpse.ratios.ny.nb.nl),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 23), "red", rep("black", 11)), cex = .4)

dotchart(sort(rmpse.ratios.nm.nb.nl),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 13), "red", rep("black", 11)), cex = .4)

mtext("Figure A.2: Ratios of Post-Treatment RMSPE to Pre-Treatment RMSPE (No Lagged DVs, Bordering States Removed)", side = 3, line = 4, font = 2)

dotchart(sort(rmpse.ratios.Illinois.nb.nl),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 19), "red", rep("black", 7)), cex = .4)

dotchart(sort(rmpse.ratios.Conn.nb.nl),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 24), "red", rep("black", 5)), cex = .4)

dotchart(sort(rmpse.ratios.NJ.nb.nl),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 18), "red", rep("black", 10)), cex = .4)

dotchart(sort(rmpse.ratios.Delaware.nb.nl),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 2), "red", rep("black", 26)), cex = .4)

dotchart(sort(rmpse.ratios.Maryland.nb.nl),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 22), "red", rep("black", 7)), cex = .4)

```


```{r, echo=FALSE, warning=FALSE, fig.width=14, fig.align="center", fig.height=8, out.width="7in"}

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))

dotchart(sort(rmpse.ratios.ny.diff.vars.no.lag),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 22), "red", rep("black", 11)), cex = .4)

dotchart(sort(rmpse.ratios.nm.diff.vars.no.lag),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 6), "red", rep("black", 23)), cex = .4)

mtext("Figure A.3: Ratios of Post-Treatment RMSPE to Pre-Treatment RMSPE (No Lagged DVs, Alternative Predictors)", side = 3, line = 4, font = 2)

dotchart(sort(rmpse.ratios.Illinois.diff.vars.no.lag),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 26), "red", rep("black", 7)), cex = .4)

dotchart(sort(rmpse.ratios.Conn.diff.vars.no.lag),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 27), "red", rep("black", 5)), cex = .4)

dotchart(sort(rmpse.ratios.NJ.diff.vars.no.lag),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 11), "red", rep("black", 19)), cex = .4)

dotchart(sort(rmpse.ratios.Delaware.diff.vars.no.lag),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 6), "red", rep("black", 26)), cex = .4)

dotchart(sort(rmpse.ratios.Maryland.diff.vars.no.lag),
         xlab="Post-Period RMSPE / Pre-Period RMSPE",
         pch=19, color = c(rep("black", 14), "red", rep("black", 7)), cex = .4)

```

\newpage

\noindent\textbf{Appendix F: Graphs From Running the Models with Alternative Predictors}

This Appendix provides the synthetic control graphs for models in which I replace “Direct Police Expenditures Per Capita” with "Police Officers Per 1,000 Residents" and the "Robbery Rate" and "Property Crime Rate" variables with "Prisoners Per 100,000 Residents."  The graphs strongly resemble those from Figure 1.

```{r, echo=FALSE, warning=FALSE, fig.width=14, fig.align="center", fig.height=8, out.width="7in"}

### New York 

par(oma = c(0,0,4,0), mar = c(2.5, 2.5, 2.5, 2.5), pch=20, mfrow=c(3, 3))
path.plot(synth.res = synth.out.diff.vars, dataprep.res = new.york.effect.diff.vars, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New York", Ylim = c(0,5))
abline(v=2004, col = "red")

### New Mexico


path.plot(synth.res = synth.out.2.diff.vars, dataprep.res = nm.effect.diff.vars, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Mexico", Ylim = c(0,5))
abline(v=2009, col = "red")
mtext("Figure A.4: Synthetic Control Plots With Alternative Predictors (y = Log Murders Per 100,000 Residents)", side = 3, line = 4, font = 2)

### Illinois 


path.plot(synth.res = synth.out.3.diff.vars, dataprep.res = Illinois.effect.diff.vars, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Illinois", Ylim = c(0,5))
abline(v=2011, col = "red")



### Connecticut


path.plot(synth.res = synth.out.4.diff.vars, dataprep.res = Conn.effect.diff.vars, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Connecticut", Ylim = c(0,5))
abline(v=2012, col = "red")


### New Jersey


path.plot(synth.res = synth.out.5.diff.vars, dataprep.res = NJ.effect.diff.vars, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "New Jersey", Ylim = c(0,5))
abline(v=2007, col = "red")


### Delaware


path.plot(synth.res = synth.out.6.diff.vars, dataprep.res = Delaware.effect.diff.vars, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Delaware", Ylim = c(0,5))
abline(v=2016, col = "red")


### Maryland

path.plot(synth.res = synth.out.7.diff.vars, dataprep.res = Maryland.effect.diff.vars, Ylab = "Murder Rate", Xlab = "Year", Legend = NA, Main = "Maryland", Ylim = c(0,5))
abline(v=2013, col = "red")

legend.cols <- c("black", "black", "red")
names(legend.cols) <- c("Treated", "Synthetic Control", "Year Eliminated DP")
par(fig= c(0, 1, 0, 1), oma = c(0,0,0,0), mar = c(.5, .5, .5, .5), new=TRUE)
plot(0,0, type = "n", bty="n", xaxt ="n", yaxt="n")
legend("bottom", text.width=c(0.3,0.3,0.3), legend=names(legend.cols), col = legend.cols, lty = c(1,2,1), lwd = c(2.5, 2.5, 2.5), cex = .75, xpd = TRUE, horiz = F, inset = c(0,0,0), bty = "y", text.font = 2)

```

\newpage

\noindent\textbf{References}

\doublespacing\noindent Abadie, Alberto, and Javier Gardeazabal. “The Economic Costs of Conflict: A Case Study of the Basque Country.” _The American Economic Review_, vol. 93, no. 1, 2003, pp. 113–132.
\doublespacing

\doublespacing\noindent Abadie, Alberto, et al. “Comparative Politics and the Synthetic Control Method.” _American Journal of Political Science_, vol. 59, no. 2, 2015, pp. 495–510.
\doublespacing

\doublespacing\noindent Abadie, Alberto, et al. “Synth: An R Package for Synthetic Control Methods in Comparative Case Studies.” _Journal of Statistical Software_, vol. 42, no. 13, 2011, pp. 1–17.
\doublespacing

\doublespacing\noindent Abadie, Alberto, et al. “Synthetic Control Methods for Comparative Case Studies: Estimating the Effect of California's Tobacco Control Program.” _Journal of the American Statistical Association_, vol. 105, no. 490, 2010, pp. 493–505.
\doublespacing

\doublespacing\noindent Abadie, Alberto. “Using Synthetic Controls: Feasibility, Data Requirements, and Methodological Aspects.” _Journal of Economic Literature_, forthcoming.
\doublespacing

\doublespacing\noindent Albert, C. J. “Challenging Deterrence: New Insight on Capital Punishment Derived from Panel Data.” University of Pittsburgh Law Review, vol. 60, no. 2, 1999, pp. 321-371.
\doublespacing

\doublespacing\noindent Bailey, William C. “Deterrence, Brutalization, and the Death Penalty: Another Examination of Oklahoma’s Return to Capital Punishment.” _Criminology_, vol. 36, no. 4, 1998, pp. 711-733.
\doublespacing

\doublespacing\noindent Berk, Richard. “New Claims about Executions and General Deterrence: Deja Vu All Over Again?” _Journal of Empirical Legal Studies_, vol. 2, no. 2, 2005, pp. 303–330.
\doublespacing

\doublespacing\noindent Bifulco, Robert et al. "Using Synthetic Controls to Evaluate the Effect of Unique Interventions: The Case of Say Yes to Education." _Evaluation Review_, vol. 41, no.6, 2017, pp. 593-619.
\doublespacing

\doublespacing\noindent Bischof, Daniel and Markus Wagner, "Do Voters Polarize When Radical Parties Enter Parliament?" _American Journal of Political Science_, vol. 63, no. 4, 2019, pp. 888-904.
\doublespacing

\doublespacing\noindent Botosaru, Irene, and Bruno Ferman. "On the Role of Covariates in the Synthetic Control Method." _Econometrics Journal_, vol. 22, no. 2, 2019, pp. 117-130.
\doublespacing

\doublespacing\noindent Bowers, W.J., and J.L. Pierce. “The Illusion of Deterrence in Isaac Ehrlich’s work on Capital Punishment.” _Yale Law Journal_ vol. 85, no. 2, 1975, pp. 187-208.
\doublespacing

\doublespacing\noindent Brumm, Harold J., and Dale O. Cloninger. “Perceived Risk of Punishment and the Commission of Homicides: A Covariance Structure Analysis.” _Journal of Economic Behavior and Organization_, vol. 31, no. 1, 1996, pp. 1-11.
\doublespacing

\doublespacing\noindent Chalfin, Aaron, et al. "What Do Panel Studies Tell Us About a Deterrent Effect
of Capital Punishment? A Critique of the Literature." _Journal of Quantitative Criminology_, vol. 29, no. 5, 2013, pp. 5–43.
\doublespacing

\doublespacing\noindent Chressanthis, George A. "Capital Punishment and the Deterrent Effect Revisited: Recent Time-Series Econometric Evidence." _Journal of Behavioral Economics_, vol. 18, no. 2, 1989, pp. 81-97
\doublespacing

\doublespacing\noindent Cover, James Peery and Paul D. Thistle. “Time Series, Homicide, and the Deterrent Effect of Capital Punishment.” _Southern Economic Journal_, vol. 54, no. 3, 1988, pp. 615-22.
\doublespacing

\doublespacing\noindent “Death Penalty.” _Gallup.com_, Gallup, 31 Jan. 2020, news.gallup.com/poll/1606/death-penalty.aspx.
\doublespacing

\doublespacing\noindent Dezhbakhsh, Hashem, and Joanna Shepherd. “The Deterrent Effect of Capital Punishment: Evidence From a ‘‘Judicial Experiment.’” _Economic Inquiry_, vol. 44, no. 3, 2006, pp. 512–535.
\doublespacing

\doublespacing\noindent Dezhbakhsh, Hashem, et al. “Does Capital Punishment Have a Deterrent Effect? New Evidence from Postmoratorium Panel Data.” _American Law and Economics Review_, vol. 5, no. 2, 2003, pp. 344–376.
\doublespacing

\doublespacing\noindent Dezhbakhsh, Hashem, and Paul H. Rubin, "From the ‘Econometrics of Capital Punishment’ to the ‘Capital Punishment’ of Econometrics: On the Use and Abuse of Sensitivity Analysis." _Applied Economics_, vol. 43, no. 25, 2011, pp. 3655-3670.

\doublespacing\noindent Donohue, John, and Justin Wolfers. “Estimating the Impact of the Death Penalty on Murder.” _American Law and Economics Review_, vol. 11, no. 2, 2009, pp. 249–309.
\doublespacing

\doublespacing\noindent Donohue, John, and Justin Wolfers. “Uses and Abuses of Empirical Evidence in the Death Penalty Debate.” _Stanford Law Review_, vol. 58, no. 3, 2005, pp. 791–845.
\doublespacing

\doublespacing\noindent Donohue, John, et al. “Right-to-Carry Laws and Violent Crime: A Comprehensive Assessment Using Panel Data and a State-Level Synthetic Controls Analysis.” _Journal of Empirical Legal Studies_, vol. 16, no. 2, 2019, pp. 198–247.
\doublespacing

\doublespacing\noindent Ehrlich, Isaac. “Capital Punishment and Deterrence: Some Further Thoughts and Additional Evidence.” _Journal of Political Economy_, vol. 85, no. 4, 1977, pp. 741–788.
\doublespacing

\doublespacing\noindent Ehrlich, Isaac. “The Deterrent Effect of Capital Punishment: A Question of Life and Death.” _The American Economic Review_, vol. 65, no. 3, 1975, pp. 397–417.
\doublespacing

\doublespacing\noindent Ehrlich, Isaac, and Zhiqiang Liu. “Sensitivity Analysis of the Deterrence Hypothesis: Lets Keep the Econ in Econometrics,” _Journal of Law and Economics_, vol. 42, no. 1, pp. 455-488.
\doublespacing

\doublespacing\noindent Eren, Ozkan, and Serkan Ozbeklik. “What Do Right-to-Work Laws Do? Evidence from a Synthetic Control Method Analysis.” _Journal of Policy Analysis and Management_, vol. 35, no. 1, 2015, pp. 173–194.
\doublespacing

\doublespacing\noindent Eren, Ozkan, and Serkan Ozbeklik. “What Do Right-to-Work Laws Do? Evidence from a Synthetic Control Method Analysis.” _Journal of Policy Analysis and Management_, vol. 35, no. 1, 2015, pp. 173–194.
\doublespacing

\doublespacing\noindent Fagan, Jeffrey. “Death and Deterrence Redux: Science, Law and Casual Reasoning on Capital Punishment.” _Ohio State Journal of Criminal Law_, vol. 4, no. 1, 2006, pp. 255–320.
\doublespacing

\doublespacing\noindent Ferman, Bruno and Cristine Pinto. "Revisiting the Synthetic Control Estimator." MPRA Paper No. 86495, 2016.
\doublespacing

\doublespacing\noindent Fox, James Alan, and Marc L. Swatt. “Multiple Imputation of the Supplementary Homicide Reports, 1976–2005.” _Journal of Quantitative Criminology_, vol. 25, no. 1, 2008, pp. 51–77.
\doublespacing

\doublespacing\noindent Fridel, Emma E., and James Alan Fox. “Gender Differences in Patterns and Trends in U.S. Homicide, 1976–2017.” _Violence and Gender_, vol. 6, no. 1, 2019, pp. 27–36.
\doublespacing

\doublespacing\noindent Gilens, Martin et al. "Campaign Finance Regulations and Public Policy." _American Political Science Review_, forthcoming 2021.
\doublespacing

\doublespacing\noindent Gius, Mark. "Using the Synthetic Control Method to Determine the Effects of the Death Penalty on State-Level Murder Rates." _Justice Policy Journal_, vol. 17, no. 2, 2020, p. 1-10.
\doublespacing

\doublespacing\noindent Grogger, Jeffrey. “The Deterrent Effect of Capital Punishment: An Analysis of Daily Homicide Counts.” _Journal of the American Statistical Association_, vol. 85, no. 410, 1990, pp. 295-303.
\doublespacing

\doublespacing\noindent Hoenack, Stephen A. and William C. Weiler. “A Structural Model of Murder Behavior and the Criminal Justice System.” _American Economic Review_, vol. 70, no. 3, 1980, pp. 327-41.
\doublespacing

\doublespacing\noindent Kaplan, Jacob. _Jacob Kaplan’s Concatenated Files: Uniform Crime Reporting Program Data: Offenses Known and Clearances by Arrest, 1960-2018._ Inter-university Consortium for Political and Social Research, 2020.
\doublespacing

\doublespacing\noindent Katz, Lawrence, et al. “Prison Conditions, Capital Punishment, and Deterrence.” _American Law and Economics Review_, vol. 5, no. 2, 2003, pp. 318–343.
\doublespacing

\doublespacing\noindent Kaul, Ashok et al., "Synthetic Control Methods: Never Use All Pre-Intervention Outcomes Together With Covariates." MPRA Paper No. 83790, 2016. 
\doublespacing

\doublespacing\noindent Kovandzic, Tomislav, et al. “Does the Death Penalty Save Lives? New Evidence from State Panel Data, 1977 to 2006.” _Criminology & Public Policy_, vol. 8, no. 4, 2009, pp. 803–843.
\doublespacing

\doublespacing\noindent Kreif, Noemi, et al. “Examination of the Synthetic Control Method for Evaluating Health Policies with Multiple Treated Units.” _Health Economics_, 2016, pp. 1514–1528.
\doublespacing

\doublespacing\noindent Layson, Stephen K. "Homicide and Deterrence: A Reexamination of the United States Time-Series Evidence." _Southern Economic Journal_, vol. 52, no. 1, 1985, pp. 68-89.
\doublespacing

\doublespacing\noindent Land, Kenneth, et al. “The Short-Term Effects of Executions on Homicides: Deterrence, Displacement, or Both.” _Criminology_, vol. 47, no. 4, 2009, pp. 1009–1043.
\doublespacing

\doublespacing\noindent Leamer, Edward E. "Let's Take the Con Out of Econometrics." _American Economic Review_, vol. 73, no. 1, 1983, pp. 31-43.
\doublespacing

\doublespacing\noindent Liu, Zhiqiang. “Capital Punishment and the Deterrence Hypothesis: Some New Insights and Empirical Evidence.” _Eastern Economic Journal_, vol. 30, no. 3, 2004, pp. 237–258.
\doublespacing

\doublespacing\noindent Lott, John R., Jr. and William M. Landes. “Multiple Victim Public Shootings.” Olin Law and Economics Working Paper No. 73. 2000. University of Chicago.
\doublespacing

\doublespacing\noindent McAleer, Michael, and Michael R. Veall. “How Fragile are Fragile Inferences? A Re-evaluation of the Deterrent Effect of Capital Punishment.” _Review of Economics and Statistics_ vol. 71, no. 1, 1989, pp. 99-106.
\doublespacing

\doublespacing\noindent McManus, W. “Estimates of the Deterrent Effect of Capital Punishment: The Importance of the Researcher’s Prior Beliefs.” _Journal of Political Economy_, vol. 93, no. 2, 1985, pp. 417-425.
\doublespacing

\doublespacing\noindent Mocan, H.  Naci, and R.  Kaj Gittings. “Getting off Death Row: Commuted Sentences and the Deterrent Effect of Capital Punishment.” _The Journal of Law and Economics_, vol. 46, no. 2, 2003, pp. 453–478.
\doublespacing

\doublespacing\noindent Mocan, H. Naci, and R. Kaj Gittings. “The Impact of Incentives on Human Behavior: Can We Make It Disappear? The Case of the Death Penalty.” In _The Economics of Crime: Lessons For and From Latin America_, edited by Rafael Di Tella, Sebastian Edwards, and Ernesto Schargrodsky. Chicago and London: University of Chicago Press, 2010, pp. 379–420
\doublespacing

\doublespacing\noindent Nagin, Daniel, and John Pepper, editors. _Deterrence and the Death Penalty._ National Research Council, 2012.
\doublespacing

\doublespacing\noindent Renberg, Kristen M. "The Impact of Retention Systems on Judicial Behavior: a Synthetic Controls Analysis of State Supreme Courts." _Justice System Journal_, vol. 41, no. 4, 2020, pp. 292-312.
\doublespacing

\doublespacing\noindent Sellin, Thorsten. _The Death Penalty._ American Law Institute, 1959.
\doublespacing

\doublespacing\noindent Shepherd, Joanna. “Deterrence versus Brutalization: Capital Punishment's Differing Impacts among States.” _Michigan Law Review_, vol. 104, no. 2, 2005, pp. 203–256.
\doublespacing

\doublespacing\noindent Shepherd, Joanna. “Murders of Passion, Execution Delays, and the Deterrence of Capital Punishment.” _The Journal of Legal Studies_, vol. 33, no. 2, 2004, pp. 283–321.
\doublespacing

\doublespacing\noindent Sommeiller, Estelle, and Mark Price. _The New Gilded Age: Income Inequality in the U.S. by State, Metropolitan Area, and County._ Economic Policy Institute, 18 July 2018, www.epi.org/publication/the-new-gilded-age-income-inequality-in-the-u-s-by-state-metropolitan-area-and-county/.
\doublespacing

\doublespacing\noindent Sorenson, Jon, et al. “Capital Punishment and Deterrence: Examining the Effect of Executions on Murder in Texas.” _Crime & Delinquency_, vol. 45, no. 4, 1999, pp. 481-493.
\doublespacing

\doublespacing\noindent Steiker, Carol S., and Jordan M. Steiker. _Courting Death_. The Belknap Press of Harvard University Press, 2016. 
\doublespacing

\doublespacing\noindent Stolzenberg, Lisa, and Stewart J. D'alessio. “Capital Punishment, Execution Publicity and Murder in Houston, Texas.” _The Journal of Criminal Law and Criminology_, vol. 94, no. 2, 2004, pp. 351–380.
\doublespacing

\doublespacing\noindent Xu, Yiqing. "Generalized Synthetic Control Method: Causal Inference with Interactive Fixed Effects Models", _Political Analysis_, vol. 25, no. 1, 2017, pp. 57-76.
\doublespacing

\doublespacing\noindent Zimmerman, Paul R. “State Executions, Deterrence, and the Incidence of Murder.” _Journal of Applied Economics_, vol. 7, no. 1, 2004, pp. 163–193.
\doublespacing

\doublespacing\noindent Zimmerman, Paul R. “Estimates of the Deterrent Effect of Alternative Execution Methods in the United States: 1978-2000.” _The American Journal of Economics and Sociology_, vol. 65, no. 4, 2006, pp. 909–942.
\doublespacing

\doublespacing\noindent Zimmerman, Paul R. “Statistical Variability and the Deterrent Effect of the Death Penalty.” _American Law and Economics Review_ vol. 11, no. 2, 2009, pp. 370–98.
\doublespacing

\doublespacing\noindent Zimmerman, Paul R. , “The Economics of Capital Punishment and Deterrence.” In _Handbook on the Economics of Crime_, edited by Bruce Benson and Paul Zimmerman. Edward Elgar Publishers, 2010.


